- You can send a
DELETE
request to/api/issues/{projectname}
with an_id
to delete an issue. If no_id
is sent, the return value is{ error: 'missing _id' }
. On success, the return value is{ result: 'successfully deleted', '_id': _id }
. On failure, the return value is{ error: 'could not delete', '_id': _id }
.
Here is my code for the .delete:
.delete(function(req, res) {
var project = req.params.project;
console.log(`delete from ${project}`);
//return if no id sent
if (!req.body._id) {
return res.json({ error: 'missing _id' });
}
//find and remove in order to delete issue
Issue.findByIdAndRemove(req.body._id, function(err, doc) {
if (!doc || err) {
return res.status(500).json({ error: 'could not delete', _id: req.body._id });
} else {
return res.status(200).json({ result: 'successfully deleted', _id: req.body._id });
}
})
});
I think it may be casued by the issue not being in the database but I would assume that free code camps tests would setup an issue to delete when it goes to call the .delete function?
Any help or guidance would be greatly appreciated… I’ve been stuck on this project for weeks! Thank you.
solution: https://boilerplate-project-issuetracker-6--dominick253.repl.co
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36
Challenge: Quality Assurance Projects - Issue Tracker
Link to the challenge: