2
我基本上試圖在請求模塊中使用PUT請求在JSON數組中設置一個值。該數組有多個主對象,我只想將它設置爲其中的一個。它的格式如下:如何把一個JSON數組中的某個對象(npm請求)
[
0: {
status: 'pending'
}
1: {
status: 'pending'
}
]
而且我用這個例子腳本從「新公共管理要求」的文件:
request({
method: 'PUT',
preambleCRLF: true,
postambleCRLF: true,
uri: 'http://service.com/upload',
multipart: [
{
'content-type': 'application/json',
body: JSON.stringify(-what-goes-in-here-?-
}
],
function (error, response, body) {
if (error) {
return console.error('upload failed:', error);
}
console.log('Upload successful! Server responded with:', body);
})
因此,最大的問題是什麼,我把「身體:」來使其成爲PUT,說,0:{狀態:'批准'}而不是1:{狀態:'批准'}
我感謝任何幫助,我可以闡述更多,如果需要。 :)
您需要進一步闡明,您所引用的「身體」是什麼,爲什麼不包括在內? –