繁体   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