【发布时间】:2015-05-31 22:19:44
【问题描述】:
我是初学者...使用 Angular 节点和 mysql 创建一个 crud 应用程序
由于某种原因,我无法获取 console.log(request.body.name) 或 console.log(request.body.description) 之类的数据,我收到 505 错误.. 好像我只是打印 console.log('any message') 这会显示没有任何错误。
我在按钮上绑定了ng-click="editProductCategory()"
下面是editProductCategory() 方法
$scope.editProductCategory = function (){
productCategoryService.updateProductCategory($scope.productCategoryData, productCategoryService.getIdFromUri())
.success(function (data) {
if(data && data.status && data.status == 'successful'){
alert('updated successfully');
}
})
.error(function (err, status) {
console.log('********************************');
console.log(err);
console.log('-------------------------------');
console.log(status);
console.log('********************************');
});
}
这是我的productCategoryService.updateProductCategory
updateProductCategory: function (productCategory, productCategoryId) {
console.log(productCategory.name);
console.log(productCategory.description);
console.log(productCategoryId);
return $http.post('/updateProductCategory', {
name: productCategory.name,
description: productCategory.description,
categoryId: productCategoryId
});
}
这里是路由配置
this.routeTable.push({
requestType: 'post',
requestUrl: '/updateProductCategory',
callbackFunction: function(request, response)
{
console.log('/******* arrived successfully ********/');
//console.log(request.body.description + " no errors");
//console.log(request.param());
response.json()
}
});
this.routeTable.forEach(function(route){
if(route.requestType == 'get')
{
this.app.get(route.requestUrl, route.callbackFunction)
}
else if(route.requestType == 'post' || route.requestType == 'POST ')
{
this.app.post(route.requestUrl, route.callbackFunction);
}
else if(route.requestType == 'delete'){}
});
有什么想法吗?
【问题讨论】:
-
我没有看到你的哪一行代码中断或没有按你预期的那样工作,你能指出来吗?
-
this.routeTable.push()这个console.log(request.body.description + ' without errors')中注释的行这些行不通
标签: javascript mysql angularjs node.js angular-http