Meteor http get call

I am trying to get a working http.get client function working in Meteor. However, I continue to get my own page as a 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 expect it to return a json object containing weather information. Am I missing something here?

Thanks.

+4
source share
1 answer

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

Also, make this call from your server, i.e. create a method containing the above code and call this method with Meteor.call() ;

See Meteor.methods () and Meteor.call ()

+8
source

Source: https://habr.com/ru/post/1490883/


All Articles