我想访问远程服务器API并需要进行ajax调用。最好是在服务器端完成,以免危及API密钥。使用meteor应该如何实现呢?
meteor add http
。 然后您可以像这样使用它:var result = HTTP.call("GET", "http://api.twitter.com/xyz",
{params: {user: userId}});
Meteor.http.post
(文档在这里)。类似以下内容:Meteor.http.post(API_URL, {foo: 'bar', other: 'data'}, function(err, result) {
if (!err)
// do something with the result.
});