![](/img/trans.png)
[英]How to consume POST call where parameter is of type application/x-www-form-urlencoded in node js
[英]node js how to call webapi( x-www-form-urlencoded ) by sending data
我使用了 npm 包queryString並做了這樣的事情:
var formdata=queryString.stringify({
SOMEDATA: SOMEVALUE,
MOREDATA: MOREVALUE
});
var options={
hostname: <hostname>,
path: <path>
method: 'POST',
headers:{
'Content-Type':'application/x-www-form-urlencoded',
'Content-Length': formdata.length
}
}
let request = https.request(options,function(response){
//do something with the response data here
}
request.write(formdata);
request.end();
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.