在角js中POST http:// localhost:8080 / projects1 400(错误请求)

时间:2016-06-29 16:56:56

标签: angularjs node.js

的index.html

<input type="text" ng-model="project_name"/>
<button ng-click="add_project()">Add Project</button>

controller.js

$scope.add_project = function add_project(){
  console.log($scope.project_name);
  $http.post('/projects', $scope.project_name).success(function(response) {
    console.log(response);
    refresh();
  });
};

server.js

app.post('/projects',function (req, res){
  console.log(req.body);
  db.projects.insert(req.body, function(err, doc) {
    res.json(doc);
  });
});

当我点击按钮时,我收到错误:

  

angular.js:11821 PUT http://localhost:8080/projects1 400(错误请求)

不确定如何解决此问题。

0 个答案:

没有答案