Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

how to create request body javascript

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

var postData = {
    'Value1' : 'abc1',
    'Value2' : 'abc2',
    'Value3' : '3'
};
var postBody = querystring.stringify(postData);

var options = {
    host: 'URL'
    port: 443,
    path: 'PATH'
    method: 'POST',
    headers: {
        'Content-Type': 'application/x-www-form-urlencoded',
        'Content-Length': postBody.length
  }
};

var req = https.request(options, function(res) {
  console.log(res.statusCode);
  res.on('data', function(d) {
    process.stdout.write(d);
  });
});
req.write(postBody);
req.end();

req.on('error', function(e) {
  console.error(e);
});
Comment

PREVIOUS NEXT
Code Example
Javascript :: is js object oriented 
Javascript :: js reduce 
Javascript :: line break in js 
Javascript :: mometjs 
Javascript :: react function 
Javascript :: react native diasble view 
Javascript :: how to install exact package lock version in package-lock.json 
Javascript :: how to get json response from rest api in node js 
Javascript :: js array remove undefined values 
Javascript :: kafka nodejs example 
Javascript :: every() method 
Javascript :: Setting axios base url dynamically 
Javascript :: react native expo flatlist 
Javascript :: js array as parameter 
Javascript :: new line in javascript string 
Javascript :: Relative Time momentjs 
Javascript :: datatable on change event jquery 
Javascript :: .includes is not a function 
Javascript :: react-dropzone 
Javascript :: discord.js if no arguments 
Javascript :: get keys of object js 
Javascript :: where is select value in javascript event object 
Javascript :: vuejs delay watch 
Javascript :: jquery onclick multiple buttons 
Javascript :: last element of array 
Javascript :: shadow class angular 
Javascript :: deno vs nodejs 
Javascript :: react native conditional rendering 
Javascript :: how to code a discord bot in javascript 
Javascript :: usestate in react js 
ADD CONTENT
Topic
Content
Source link
Name
1+4 =