Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

javascript https post

const querystring = require('querystring');
const https = require('https');

var postData = querystring.stringify({
    'msg' : 'Hello World!'
});

var options = {
  hostname: 'posttestserver.com',
  port: 443,
  path: '/post.php',
  method: 'POST',
  headers: {
       'Content-Type': 'application/x-www-form-urlencoded',
       'Content-Length': postData.length
     }
};

var req = https.request(options, (res) => {
  console.log('statusCode:', res.statusCode);
  console.log('headers:', res.headers);

  res.on('data', (d) => {
    process.stdout.write(d);
  });
});

req.on('error', (e) => {
  console.error(e);
});

req.write(postData);
req.end();
Comment

PREVIOUS NEXT
Code Example
Javascript :: js copy values from one array to another node new 
Javascript :: how to import npm module 
Javascript :: redux mapstatetoprops get props 
Javascript :: leaflet remove layergroup 
Javascript :: multiple styles in react native 
Javascript :: react router link with params 
Javascript :: github remote 
Javascript :: javascript arr.flat 
Javascript :: javascript search for words in sentence examples 
Javascript :: new line in rdlc expression 
Javascript :: ant design charts 
Javascript :: firebase.apps.length 
Javascript :: js fetch catch 401 
Javascript :: formik seterrors 
Javascript :: How to convert a canvas to an image javascript 
Javascript :: javascript change select element 
Javascript :: express js hello world example 
Javascript :: paragraph antd 
Javascript :: jquery carousel slide event 
Javascript :: ANGULAR locale fr 
Javascript :: count in string javascript 
Javascript :: mongoose findone multiple conditions 
Javascript :: array spread operator in javascript 
Javascript :: map a square to a circle 
Javascript :: window location any web 
Javascript :: fs.appendFileSync in nodejs 
Javascript :: after effects loop wiggle 
Javascript :: js sort integer array 
Javascript :: get location from brwoser react 
Javascript :: discord js embeded message hyperlink 
ADD CONTENT
Topic
Content
Source link
Name
4+6 =