Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTTP.get request stuck in a redirect loop

I have the below lines in my code:

postUrl =  "http://www.nytimes.com/2014/03/08/world/asia/ malaysia-airlines-says-plane-with-over-200-aboard-is-missing.html";

var htmlResult = cheerio.load(Meteor.http.call("GET", postUrl, {options: {followRedirects:false}}).content);

I get the following error:

Error: Exceeded maxRedirects. Probably stuck in a redirect loop

I try the same code with other URL and it works but It's throwing this exception with the NTY url. I'm basically trying to get the HEAD of the page.

like image 616
Emre Kenci Avatar asked Mar 08 '14 20:03

Emre Kenci


Video Answer


1 Answers

Use this.

In your http.get call you should pass {jar: true}

For example:

HTTP.get(url, {jar: true})

This worked for me at least :)

like image 52
bill-lamin Avatar answered Sep 17 '22 23:09

bill-lamin