无法将数据传递给 PUT 请求
Unable to pass data to a PUT request
我正在尝试使用 Superagent 向 mongoDB 记录发送更新。
我在 URL 中传递了对象的 _id,但我似乎无法将新数据传递给超级代理。
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
此问题是由于对 mongoose 的更新请求不正确造成的。
数据 = "unidentified" 与它无关。
我正在尝试使用 Superagent 向 mongoDB 记录发送更新。 我在 URL 中传递了对象的 _id,但我似乎无法将新数据传递给超级代理。
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
此问题是由于对 mongoose 的更新请求不正确造成的。 数据 = "unidentified" 与它无关。