I have to sent a post request to my node server running localhost:3001. I successfully completed the request and getting the post data in node server but the data is poorly formatted.
AngularJS:
function MyCtrl1($scope,$http,$location) {
$scope.user = { };
$scope.login = function() {
$http.post("http://localhost:3001/login",
$scope.user,
{'Content-Type': 'application/json'}).success(function(result) {
$scope.resultPost = result;
$location.path('/');
}).error(function() {
console.log("error");
});
};
}
Nodejs:
app.post('/login', function(req,res) {
console.log(JSON.stringify(req.body));
res.end('ok');
});
log : {"{\"username\":\"test\",\"password\":\"pass123\"}":""}
is there any way to get a formatted data here?