I post data to node application from a cordova app using angular $http.
I tried several 'content-type', and only 'application/x-www-form-urlencoded' can be sent to the node server successfully, so my code is like:
$http({
url: CONSTANTS.login_url,
method: "POST",
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
},
data: {"foo": "bar"},
})
But in the node application, the data I got from req.body is:
{"{"foo":"bar"}":""}
The key of the body is a String.
But my excepted result should be an Object like:
{
"foo": "bar",
}
There is a similar question in SO, the reason is that he uses 'JSON.stringify' in the frontend. But I don't use stringify why I can't get the excepted data?