Wednesday 30 October 2019

Unable to send response to front end using express router

I have a route like this -router.post('/fetch', common.fetch, function(req,res,next){util.log("Sending the response to frontend");return res.send(res.message);})This is being called via front end, I do some data manipulation in common.fetch function. Last few lines of my common.fetch are like this -common.fetch = function(req,res,next){util.log("API Call succesful");util.log("Parsed received data from API");message.data = parsedBody.data;util.log("Attached received data to body");res.message = message;util.log("Sending response to next()");return next();}All logs are being printed so there is no problem in fetch function but Sending the response to frontend log is not getting printed. I am not sure why. This route is throwing 500. I am out of every way to debug this. Any help would be appreciated.

Submitted October 30, 2019 at 07:29AM by GhostFoxGod

No comments:

Post a Comment