How to use the http.request function in http

To help you get started, we’ve selected a few http examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github surmon-china / simple-netease-cloud-music / src / netease.js View on Github external
return new Promise((resolve, reject) => {
            const req = http.request(options, res => {
                res.setEncoding('utf8')
                this[onResponse](res, resolve, reject)
            })

            req.on('error', err => {
                console.error(`problem with request: ${err.message}`)
            })

            // write data to request body
            if (form) {
                req.write(form)
            }
            req.end()
        })
    }
github arithmetric / lambda-stash / handlers / shipHttp.js View on Github external
return new Promise(function(resolve, reject) {
    var http = require('http');
    var url = require('url');
    var options = url.parse(config.http.url);
    options.method = 'POST';
    var req = http.request(options, function(res) {
      console.log('Received HTTP response status code: ' + res.statusCode);
      resolve(config);
    });
    req.on('error', function(err) {
      reject('An error occurred when making an HTTP request: ' + err);
    });
    var keyData = config.http.keyData || 'data';
    req.write(config[keyData]);
    req.end();
  });
};
github surmon-china / simple-netease-cloud-music / dist / netease.js View on Github external
return new Promise(function (resolve, reject) {
                var req = http.request(options, function (res) {
                    res.setEncoding('utf8');
                    _this[onResponse](res, resolve, reject);
                });

                req.on('error', function (err) {
                    console.error('problem with request: ' + err.message);
                });

                if (form) {
                    req.write(form);
                }
                req.end();
            });
        }
github qawemlilo / nodeza / lib / xmlrpc.js View on Github external
_.each(pingList, function (pingHost) {
    let options = {
      hostname: pingHost.host,
      path: pingHost.path,
      method: 'POST'
    };
    let req;

    req = http.request(options);
    req.write(pingXML);
    req.on('error', function (error) {
      console.error(error.stack);
    });
    req.end();
  });
}
github pqvst / checkout / lib / validate-vat.js View on Github external
return new Promise((resolve, reject) => {
    let buffer = '';

    const req = http.request(options, (res) => {
      res.setEncoding('utf8');
      res.on('data', chunk => buffer += chunk);
      res.on('end', () => resolve(buffer));
    });
    
    req.on('error', (err) => reject(err));
    req.write(payload);
    req.end();
  });
}

http

security holding package

Unknown
Latest version published 5 years ago

Package Health Score

47 / 100
Full package analysis