2018-07-07 02:20:14 +00:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
//var request = require('@coolaj86/urequest');
|
|
|
|
// To check and make sure the outputs are the same
|
|
|
|
//var request = require('request');
|
|
|
|
var request = require('../');
|
|
|
|
|
|
|
|
// will redirect to https://www.github.com and then https://github.com
|
|
|
|
//request('http://www.github.com', function (error, response, body) {
|
|
|
|
request(
|
|
|
|
{ url: 'http://postb.in/2meyt50C'
|
2018-07-07 04:40:28 +00:00
|
|
|
, method: 'POST'
|
2018-07-07 02:20:14 +00:00
|
|
|
, headers: { 'X-Foo': 'Bar' }
|
|
|
|
, form: { foo: 'bar', baz: 'qux' }
|
|
|
|
}
|
|
|
|
, function (error, response, body) {
|
|
|
|
if (error) {
|
|
|
|
console.log('error:', error); // Print the error if one occurred
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
console.log('statusCode:', response.statusCode); // The final statusCode
|
|
|
|
console.log('Body Length:', body.length); // body length
|
|
|
|
}
|
|
|
|
);
|