search

Home  >  Q&A  >  body text

angular.js - How express accepts data from angular using $http.post

I used angular to post an object to the node server, similar to:

var obj = {};
obj.title = "title";
obj.data = {expire:new Date(), detail:{data:[1,2,3]}}
$http.post('host', {obj:obj})
.success(function(suc){
//success callback
})

Node uses express3.x. The data in req.body seems to have been processed by toString(), and the nested objects are parsed into empty strings. I don’t know what to do?

大家讲道理大家讲道理2836 days ago843

reply all(1)I'll reply

  • 怪我咯

    怪我咯2017-05-15 16:59:51

    Use the browser console
    such as the chrome console to check what the data sent looks like
    whether it is correctly converted into a JSON format string

    reply
    0
  • Cancelreply