the following code gives me the status code 301 but what i want to do is not only get the status code for this url but rather follow the redirect and get the whole path of the redirect urls + appropriate status code; eg:
http://a.com
301 Moved Permanently
http://b.com/
200 OK
//code is below
var theUrl = req.query.urlPath;
var request = require('request');
request({
url: theUrl,
followRedirect: false
}, function(error, response, body) {
console.log("the first url is", theUrl)
console.log("the first status code is", response.statusCode);
});
Curious, how can i do this?