1
我試圖發佈請求發送到API和後參數應陣列, 這是如何在捲曲使用利用應用/ node.js的發送陣列中發佈請求的X WWW窗體-urlencoded
發送它curl http://localhost:3000/check_amounts
-d amounts[]=15 \
-d amounts[]=30
我試圖這樣做,在使用的Node.js請求模塊
request.post('http://localhost:3000/check_amounts', {
form: {
'amounts[]': 15 ,
'amounts[]': 30
}
}, function(error, response, body) {
console.log(body)
res.json(body);
});
但第二量覆蓋第一個和所述API得到結果如下:amounts = [30]
然後我試圖以不同的方式
request.post('http://localhost:3000/check_amounts', {
form: {
'amounts[]': [ 15 , 30]
}
}, function(error, response, body) {
console.log(body)
res.json(body);
});
發送,但結果並不如預期的amounts = [{"0":15},{"1":30}]
注:標頭應包含「內容類型」:「應用程序/ X WWW的形式-urlencoded'not'application/json'
有沒有人可以解決這個問題?
你試過了:''金額':[15,30]'? – baf 2015-04-01 08:16:59
是的...它將被視爲對象...它沒有工作 – 2015-04-01 08:18:12