Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

https package node post request

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 :: vh not working on phone 
Javascript :: convert dict to json python 
Javascript :: how to hover the mouse on an element cypress mouseover 
Javascript :: addeventlistener keydown 
Javascript :: make the log do a jump in line js 
Javascript :: javascript simulate key press 
Javascript :: fontawesome in next js 
Javascript :: check if element has childs jquery 
Javascript :: check frequency of string in array js 
Javascript :: translatex in javascript 
Javascript :: canvas resize canvas 
Javascript :: check given path is valid or not in nodejs 
Javascript :: uniqid js 
Javascript :: convert number to k m b javascript 
Javascript :: disable option dropdown jquery 
Javascript :: how to check if localhost javascript 
Javascript :: javascript json download 
Javascript :: js get url params 
Javascript :: pyspark dataframe json string 
Javascript :: remove item jquery 
Javascript :: format JSON code javascript 
Javascript :: javascript timestamp in seconds 
Javascript :: jquery get url 
Javascript :: randomColor 
Javascript :: return a boolean if a number is divisible by 10 javascript 
Javascript :: mui textfield font color 
Javascript :: fetch json 
Javascript :: javascript detect scroll to bottom of page 
Javascript :: fetch in js 
Javascript :: connecting to mongodb using mongoose 
ADD CONTENT
Topic
Content
Source link
Name
7+4 =