如何使用Meteor.js对Dropbox API进行CURL调用

Vai*_*wal 6 dropbox-api meteor

我是Meteor.js的新手,想让我的网络应用程序与Dropbox Core API一起使用.我无法使用Meteor.js中的HTTP包进行API调用

如何在Meteor中拨打电话,类似于下面的Curl电话:

curl https://api.dropbox.com/1/account/info -H "Authorization: Bearer <access token>"
Run Code Online (Sandbox Code Playgroud)

我希望得到目录中的文件列表,但是现在我仍然坚持使用了Authentical Token.

Aks*_*hat 11

您可以使用您提到的HTTP包

添加它

meteor add http
Run Code Online (Sandbox Code Playgroud)

然后使用它(服务器端).这应该产生curl上面提出的请求.

var result = HTTP.get("https://api.dropbox.com/1/account/info", {
             headers: {
                 Authorization: "Bearer <access token>"
             }
});

console.log(result.content)
console.log(result.data) //<< JSON form (if api reports application/json as the content-type header
Run Code Online (Sandbox Code Playgroud)