I am trying to use Superagent to send an update to a mongoDB record. I pass the _id of the object in the URL but I am unable to pass the new data to Super agent it seems.
put: (url,body,callback) => { // Api.put('/api/polls/' + pollId,data
console.log('put ' + url); // path is here
console.log('obj ' + body); // data is here
superagent
.put(url)
.set('Content-Type', 'application/json')
.send(body)
.end((err, response) => {
if (err) {
console.log(err);
callback(err, null);
return;}
// here check for API failures
const confirmation = response.body.confirmation;
if (confirmation != 'success') {
// send a failure message
callback({message:response.body.message, null});
return;
}
callback(response, response.body);
})
},
``` See problem in Superagent.put call...nothing in data
This issue was caused by an incorrect update request to mongoose. The data = "unidentified" had nothing to do with it.