最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Meteor http get call - Stack Overflow

programmeradmin1浏览0评论

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
Add a ment  | 

1 Answer 1

Reset to default 8

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()

发布评论

评论列表(0)

  1. 暂无评论