NodeJS - Using Request package for sending requests


request is designed to be the simplest way possible to make http calls. It supports HTTPS and follows redirects by default.

npm install request
var request = require('request');
request('', function (error, response, body) {
  console.log('error:', error); // Print the error if one occurred
  console.log('statusCode:', response && response.statusCode); // Print the response status code if a response was received
  console.log('body:', body); // Print the HTML for the Google homepage.

Another Example.

let requestedAddress = argv.address;
let encodedAddress = encodeURIComponent(requestedAddress);
let urlToRequest = '' + encodedAddress;

    url: urlToRequest,
    json: true
}, (error, response, body) => {
    if (error) {
        console.log('Something went wrong');
    } else if (body.status === 'OK') {
        var result = body.results[0];
        console.log(`Address: ${result.formatted_address}`);
        console.log(`Address: ${}`);
        console.log(`Address: ${result.geometry.location.lng}`);
    } else if (body.status === 'ZERO_RESULTS') {
        console.log('Unable to find that address.');
    } else {
        console.log('No Results found.');