Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/42.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js 资源上的正文为空。$save_Node.js_Angularjs_Mongodb_Mean Stack - Fatal编程技术网

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无法处理请求内容