簡體   English   中英

node js 如何通過發送數據調用webapi( x-www-form-urlencoded )

[英]node js how to call webapi( x-www-form-urlencoded ) by sending data

我正在嘗試將數據發送到網絡服務,我從郵遞員應用程序中添加了數據。

我需要用 node js 來做,我找不到如何調用 webapi x-www-form-urlencoded。

有人幫我嗎?

在此處輸入圖片說明

我使用了 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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM