Friday 6 April 2018

HapiJS + Boom newbie problem

I am having a difficult time returning error response using HapiJs + BoomThis is the particular part of the code I am having trouble withexports.deleteIssue = (req, h) => { var issue = Issue.findByIdAndRemove(req.params.id, function (err,issue){ if(err) throw Boom.notFound('Issue Not Found'); fs.remove(__basedir + "/uploads/" +issue._id, err => { if (err) throw err }); console.log(_.size(issue.documents)) var documents = issue.documents; deleteAllIssueDocuments(documents) }) .populate("documents") function deleteAllIssueDocuments(documents) { _.each(documents, (document) => { var documentId = document._id; Document.findByIdAndRemove(documentId, (err, document)=>{ if(!err) console.log("Deleted Document") }) }) } return "Deleted" } So instead of nice response in the body of the request I get the error on the server.https://ift.tt/2uSqUlZ am a total beginner in Hapi and just a bit more experienced in NodeJS in general, sorry in advance for my lack of knowledge. It would be great if someone could help me here :)

Submitted April 07, 2018 at 12:52AM by AndroidDvlpr

No comments:

Post a Comment