node-restful
node-restful copied to clipboard
DELETE 404
When making a DELETE request using RESTANGULAR (AngularJS), I get
DELETE http://localhost:3000/resources 404 (Not Found)
even though my model clearly states that this method is allow:
var Resource = app.resource = restful.model('resource', mongoose.Schema({
title: 'string',
year: 'number',
})).methods(['get', 'post', 'put', 'delete']);
Resource.register(app, '/resources');
What should I check? Please advise.
Thanks
It seems like you're forgetting to include the model id in the restangular delete call.
I.e. it should be hitting the route http://localhost:3000/resources/:id
but its not including the id in the path.
Restangular should probably prevent something like this by throwing an error
Great tip.
It turns out my Restangular config was wrong. I've used MongoLab config as an example; i.e.
RestangularProvider.setRestangularFields({ id: '_id.$oid' });
But, my local MongoDB installation has no _id.$oid
, insted it should just read:
RestangularProvider.setRestangularFields({id: '_id'});
it needs proper url, seems like you've missed "id" surppose to be like this: export const deletePost = (id) => axios.delete(${url}/${id}
); in your API