当我从angularjs发送一个post请求到nodejs request.body未定义,但是当通过get方法
发送时我能够接收到值我的angularjs代码
app.controller('create_company', function($scope,$http) {
$scope.save = function() {
console.log($scope.company);
var temp=$scope.company;
$http({
url: "http://localhost:4000/comp/signUp",
method: "POST",
data: temp
}).success(function(data, status, headers, config) {
$scope.data = data;
}).error(function(data, status, headers, config) {
$scope.status = status;
});
}
我的nodejs代码:
var express = require('express');
var compRouter = express.Router();
var router = function () {
compRouter.route('/signUp')
.post(function (request, response) {
console.log(request.body);
});
return compRouter;
}