ノードをnodejsルートに送信しようとしています。私はエクスプレスルートを使用しています。ノードからノードへのデータを投稿するjs route not working
var app = angular.module("myapp", [])
app.controller("ListController2", ['$scope','getAverage','$http',function($scope, getAverage,$http) {
$scope.subjectAverages = [{
'subjectName': '',
'yearSem': '',
'studentsAppeared': '',
'studentsPassed':'',
'percentage':'',
'average':'',
'facultyComment':''
}];
$scope.save=function(){
var data =angular.toJson($scope.subjectAverages)
var objectToSerialize={'object':data};
$http({
url: 'app',
method: "POST",
data: $.param(objectToSerialize),
headers: {
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
}
}).success(function(data){
alert("done");
});
}
router.post('/app',function(res,req){
console.log(req.body);
});
ご案内してください。
あなたのノードのapp.jsに急行-bodyparserモジュールを使用してい –
はい私はそれを使用しています。 – dpak
$ .paramを使用してデータを直列化しないでください。 POSTリクエストでparamsを送ることはできません。あなたのHTTPリクエストのデータ部分に、{object:$ scope.subjectAverages} –