angular.js - How express accepts data from angular using $http.post
大家讲道理
大家讲道理 2017-05-15 16:57:51
0
1
840

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?

大家讲道理
大家讲道理

光阴似箭催人老,日月如移越少年。

reply all(1)
刘奇

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

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template