Quantcast
Channel: Active questions tagged https - Stack Overflow
Viewing all articles
Browse latest Browse all 1687

how to post data in node.js with content type ='application/x-www-form-urlencoded' with package https

$
0
0

how can the package "https" be used to send a POST Call but with urlencoded body? I can't use any package other than https

"data" needs to be URL encoded, since the target Endpoint expects it....

const options = {agent,hostname: "myTestURL.com",port: 443,path: '/foo',method: 'POST',headers: {'Content-Type': 'application/x-www-form-urlencoded',},}

let response = ''const req = https.request(options, (res) => {  res.on('data', (d) => {    response += d  })})req.on('error', (e) => {  console.error(e)})req.write(new URLSearchParams(data))req.end()

Viewing all articles
Browse latest Browse all 1687

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>