I am trying to add status to a successful update message, but I cannot add the status property to the form json object. Here is my code
apiRouter.post('/forms/update', function(req, res){ if(req.body.id !== 'undefined' && req.body.id){ var condition = {'_id':req.body.id}; Form.findOneAndUpdate(condition, req.body, {upsert:true}, function(err, form){ if (err) return res.send(500, { error: err }); var objForm = form; objForm.status = "saved successfully"; return res.send(objForm); }); }else{ res.send("Requires form id"); } });
and here is the response that I receive, there is no status notification
{ "_id": "5580ab2045d6866f0e95da5f", "test": "myname", "data": "{\"name\":3321112,\"sdfsd\"344}", "__v": 0, "id": "5580ab2045d6866f0e95da5f" }
I'm not sure what I am missing.
source share