【发布时间】:2014-01-10 22:53:28
【问题描述】:
我需要在 node.js 中使用“require”npm 来访问 api。 api 需要原始 put 数据(不是 put 字段)。 如何使用 request npm 做到这一点?
我需要发送的原始数据示例:
var body = {
"id": 123,
"squares": [
{
square_id: 345,
color: "#ccc"
},
{
square_id: 777,
color: "#fff"
}
]
}
我正在尝试,但它不起作用:
request({
method: "PUT",
uri: UPDATE_GAME,
multipart: [{
'content-type': 'application/json',
body: JSON.stringify(body)
}]
}
【问题讨论】:
标签: javascript node.js request npm put