Node.js 资源上的正文为空。$save
因此,我尝试了来自的建议Node.js 资源上的正文为空。$save,node.js,angularjs,mongodb,mean-stack,Node.js,Angularjs,Mongodb,Mean Stack,因此,我尝试了来自的建议 但我还是得到了一个空的尸体 我可以做得很好,甚至可以传递一个身份证。但我似乎无法将数据发布和传输到服务器 控制器: .controller("createEventController", ["$scope", 'CreateEventService', '$location', function($scope, CreateEventService, $location){ $scope.event = {}; $scope.submitE
.controller("createEventController", ["$scope", 'CreateEventService', '$location', function($scope, CreateEventService, $location){
$scope.event = {};
$scope.submitEvent = function(){
console.log($scope.event);
var events = new CreateEventService($scope.event);
console.log(events);
events.save(function(response){
console.log(response);
}, function(error){
console.log(error);
});
}
}])
服务
factory('CreateEventService', function($resource){
return $resource('api/createEvent');
});
更改
事件。保存(…)
到事件。$save(…)
更改事件。保存(…)
到事件。$save(…)
更改事件。保存(…)
到事件。$save(…)
更改事件。保存(…)
到事件。$save(…)
如果使用express 4.1.2,尽管bodyParser()被弃用,但
app.use(bodyParser.urlencoded({
extended: true
}));
因为某种原因,给了我一个空的身体。不管出于什么原因,以前没有urlencoded使我的服务器崩溃(我想是旧的express版本)。只需将其更改回(使用express 4.1.2)
而且是固定的。我还删除了methodOverride(),因为这会导致服务器挂起。如果有人知道更正确的方法,我将不胜感激。如果使用Express4.1.2,尽管它担心bodyParser()被弃用,但是
app.use(bodyParser.urlencoded({
extended: true
}));
因为某种原因,给了我一个空的身体。不管出于什么原因,以前没有urlencoded使我的服务器崩溃(我想是旧的express版本)。只需将其更改回(使用express 4.1.2)
而且是固定的。我还删除了methodOverride(),因为这会导致服务器挂起。如果有人知道更正确的方法,我将不胜感激。如果使用Express4.1.2,尽管它担心bodyParser()被弃用,但是
app.use(bodyParser.urlencoded({
extended: true
}));
因为某种原因,给了我一个空的身体。不管出于什么原因,以前没有urlencoded使我的服务器崩溃(我想是旧的express版本)。只需将其更改回(使用express 4.1.2)
而且是固定的。我还删除了methodOverride(),因为这会导致服务器挂起。如果有人知道更正确的方法,我将不胜感激。如果使用Express4.1.2,尽管它担心bodyParser()被弃用,但是
app.use(bodyParser.urlencoded({
extended: true
}));
因为某种原因,给了我一个空的身体。不管出于什么原因,以前没有urlencoded使我的服务器崩溃(我想是旧的express版本)。只需将其更改回(使用express 4.1.2)
而且是固定的。我还删除了methodOverride(),因为这会导致服务器挂起。如果有人知道更正确的方法,我将不胜感激。您应该使用
bodyParser.json()
。默认情况下,$resource
使用标题“Content Type”:“application/json;charset=UTF-8”
发送请求,但不使用bodyParser.json()
您的API无法处理请求内容。您应该使用bodyParser.json()
。默认情况下,$resource
使用标题“Content Type”:“application/json;charset=UTF-8”
发送请求,但不使用bodyParser.json()
您的API无法处理请求内容。您应该使用bodyParser.json()
。默认情况下,$resource
使用标题“Content Type”:“application/json;charset=UTF-8”
发送请求,但不使用bodyParser.json()
您的API无法处理请求内容。您应该使用bodyParser.json()
。默认情况下,$resource
使用标题“Content Type”:“application/json;charset=UTF-8”
发送请求,但不使用bodyParser.json()
您的API无法处理请求内容