showing results for - "javascript https post"
Jacopo
23 Feb 2016
1const querystring = require('querystring');
2const https = require('https');
3
4var postData = querystring.stringify({
5    'msg' : 'Hello World!'
6});
7
8var options = {
9  hostname: 'posttestserver.com',
10  port: 443,
11  path: '/post.php',
12  method: 'POST',
13  headers: {
14       'Content-Type': 'application/x-www-form-urlencoded',
15       'Content-Length': postData.length
16     }
17};
18
19var req = https.request(options, (res) => {
20  console.log('statusCode:', res.statusCode);
21  console.log('headers:', res.headers);
22
23  res.on('data', (d) => {
24    process.stdout.write(d);
25  });
26});
27
28req.on('error', (e) => {
29  console.error(e);
30});
31
32req.write(postData);
33req.end();
34
similar questions
queries leading to this page
javascript https post