我试图做一个http请求来删除一个帖子一切正常,但我回来的响应代码总是“1”,我不知道why.thus这会影响我的前端以及错误处理部分。我可否知道这是为什么发生? 不断获得HTTP响应代码“1”的HTTP请求
这是我迄今为止
注册HTTP请求
app.delete('/channelHandler/channel/:permalink/delete', channelHandler.deleteChannelByPermalink);
路线
后执行,我得到"no problem in route"
this.deleteChannelByPermalink = function(req, res, next){
var permalink = req.params.permalink;
channels.deleteChannelByPermalink(permalink,function(err, results) {
"use strict";
if(err){
console.log("error in route");
res.send(400,err);
}
console.log("no problem in route");
res.send(200,results);
});
}
数据库
后执行我得到"done in database"
this.deleteChannelByPermalink = function(data, callback){
"use strict"
channels.remove({'channelPermalink': data}, function(err, post) {
"use strict";
if (err) return callback(err, null);
callback(err, post);
console.log("done in database");
});
}
前端
//执行后我得到"something is wrong"
代替"LOL"
$scope.confirm = function(titleform){
if(titleform === items.currentTitle){
$http.delete('/channelHandler/channel/'+items.currentPermalink+'/delete').
success(function(data){
alert("LOL")
}).error(function(err){
alert("Something is wrong")
$scope.errorMessage = err;
});
$modalInstance.dismiss('cancel');
}else{
$scope.errorMessage = "Please enter the correct title "
}
}
感谢您指出错误,但我已经解决了我的问题。感谢您的时间,我真的很感激它。 –