我正在使用平均堆栈,我正在尝试删除图片,但遇到问题,而我找不到' 404未找到'错误。一切似乎都正确排列但由于某种原因它无法正常工作。谁能明白为什么?这就是我所拥有的:
HTML
<ul >
<li ng-repeat="photo in photos"><img ng-src="img/{{ photo.url}}" />
<button class="button btn btn-warning" ng-click="deletePics(photo._id)">Delete</button>
</li>
Angularjs
$scope.deletePics = function(id){
$http.delete('/api/admin/photos/' + id)
.then(function successCallback(response){
console.log(response);
},
function errorcallback(error){
console.log(error);
});
};
的NodeJS / Expressjs
//delete photos
apiRoutes.delete('/admin/photos/:id'),function(req,res){
console.log('deleted photos');
res.send('this works');
};
另外,api index.js正在使用apiroutes作为api
var apiRoutes = require('./apiRoute');
app.use('/api',apiRoutes);