We recommend the request library for carrying out HTTP operations from Node.js 


The snippet below shows how to securely connect to an HTTPS API via QuotaGuard Static.

  

var request = require('request');

var options = {
    proxy: process.env.QUOTAGUARDSTATIC_URL,
    url: 'https://www.google.com/',
    headers: {
        'User-Agent': 'node.js'
    }
};

function callback(error, response, body) {
    if (!error && response.statusCode == 200) {
        console.log(body);
    }
}

request(options, callback);