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

How to make a CURL call to Dropbox API using Meteor.js

我是 Meteor.js 的新手,想让我的网络应用程序与 Dropbox Core API 一起工作。我无法全神贯注地使用 Meteor.js

中的 HTTP 包进行 API 调用

如何在 Meteor 中进行类似于下面 Curl 调用的调用:

curl https://api.dropbox.com/1/account/info -H "Authorization: Bearer <access token>"

我希望获得目录中的文件列表,但现在我只能使用 Authentical Token。

您可以使用您提到的 HTTP 包

加上

meteor add http

然后使用它(服务器端)。这应该产生上面 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