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/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.
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/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.
Share Improve this question edited Jul 11, 2013 at 11:59 user229044♦ 240k41 gold badges344 silver badges346 bronze badges asked Jul 11, 2013 at 11:24 Arno KerkmeijerArno Kerkmeijer 711 silver badge3 bronze badges 1- Found my solution! In the first place you need to add the http:// of https:// in front of the URL. I used the Meteor Methods to do the stuff for me: – Arno Kerkmeijer Commented Jul 11, 2013 at 11:56
1 Answer
Reset to default 8Please 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()