我正在使用 Node.js 中的 request 模块来执行 put 请求。我的代码是这样的
var request = require('request');
var data = {foo: "bar", woo: "car"};
request({
method: 'PUT',
uri: myURL,
multipart: [{
'content-type':'application/json',
body: JSON.stringify(data)
}]
}, function(error, request, body){
console.log(body);
});
当我运行它时,我得到一个错误:
“不支持的内容类型:application/json”
最佳答案
就这样试试吧:
request({ url: url, method: 'PUT', json: {foo: "bar", woo: "car"}}, 回调)
关于javascript - Node.js - 带有 'request' 模块的 PUT,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21393706/