Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Meteor http get call

Im trying to get a working http.get client function working in Meteor. However I keep getting my own page as result.

Here is my code:

Meteor.http.get("api.openweathermap.org/data/2.5/weather?q=London,uk", function (error, result) {
if(error) {
    console.log('http get FAILED!');
} else {
    console.log('http get SUCCES');
    if (result.statusCode === 200) {
        console.log('Status code = 200!');
        console.log(result.content);
    }
}
});

I would expect that it returned a json object containing weather information. Do I miss something here?

Thanks.

like image 470
Arno Kerkmeijer Avatar asked Feb 15 '23 23:02

Arno Kerkmeijer


1 Answers

Please update the url by adding http:// at beginning.

Moreover make this call from your server, i.e. Make a method that contains the above code and call that method via Meteor.call();

Please see Meteor.methods() and Meteor.call()

like image 111
sohel khalifa Avatar answered Feb 24 '23 13:02

sohel khalifa