A lightweight, zero-dependency drop-in replacement for request.js
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

19 lines
703 B

'use strict';
//var request = require('urequest');
var request = require('../');
// would normally redirect to https://www.github.com and then https://github.com
request(
{ uri: 'https://www.github.com', followRedirect: false },
function (error, response, body) {
if (error) {
console.log('error:', error); // Print the error if one occurred
return;
}
console.log('href:', response.request.uri.href); // The final URI
console.log('statusCode:', response.statusCode); // Should be 301 or 302
console.log('Location:', response.headers.location); // The redirect
console.log('Body:', body || JSON.stringify(body));
}
);