Meteor服务器端ajax
我正在尝试访问远程服务器API,需要进行ajax调用。最好是从服务器端完成,以免损害API密钥。如何使用meteor实现这一点?如果它是RESTAPI,您可能需要使用Meteor服务器端ajax,ajax,meteor,Ajax,Meteor,我正在尝试访问远程服务器API,需要进行ajax调用。最好是从服务器端完成,以免损害API密钥。如何使用meteor实现这一点?如果它是RESTAPI,您可能需要使用meteor.http.post(docs)。比如: Meteor.http.post(API_URL, {foo: 'bar', other: 'data'}, function(err, result) { if (!err) // do something with the result. }); 这也适用于客户
meteor.http.post
(docs)。比如:
Meteor.http.post(API_URL, {foo: 'bar', other: 'data'}, function(err, result) {
if (!err)
// do something with the result.
});
这也适用于客户端。当前的方式似乎是通过包 首先将其添加到项目中,如下所示:
meteor add http
。然后你可以这样使用它:
var result = HTTP.call("GET", "http://api.twitter.com/xyz",
{params: {user: userId}});