I would like to sent response from node server to client instead of greeting the return value of function Stats.calculate(), but I cannot figure out how to do it.
router.post('/calc', (req, res) => {
request.get('a secret url api', (err,res,bodyJson) => {
if(err) console.log('error');
if(res.statusCode !== 200 ) console.log('error');
Stats.calculate(bodyJson, req.body.firstVal, req.body.secondVal);
});
res.json({greeting: "ciao"});
});
Any suggestions?