Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/meteor/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/assembly/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Meteor服务器端ajax_Ajax_Meteor - Fatal编程技术网

Meteor服务器端ajax

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. }); 这也适用于客户

我正在尝试访问远程服务器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 add http
。然后你可以这样使用它:

var result = HTTP.call("GET", "http://api.twitter.com/xyz",
  {params: {user: userId}});