问题描述
我是Meteor.js的新手,并希望使我的Web应用程序可与Dropbox Core API一起使用。我无法全神贯注地使用Meteor.js中的HTTP包进行API调用
I am new to Meteor.js and want to make my web app work with Dropbox Core API. I am not able to wrap my head around making API calls using the HTTP package in Meteor.js
如何在Meteor中进行类似于Curl调用的调用
How can I make a call in Meteor which is similar to the Curl call below :
curl https://api.dropbox.com/1/account/info -H "Authorization: Bearer <access token>"
我希望获取目录中的文件列表,但现在我仍然使用Authentical Token。
I wish to get list of files in the directory but for now I am stuck with the Authentical Token.
推荐答案
您可以使用您提到的HTTP包
You can use the HTTP package you mentioned
添加它与
meteor add http
然后使用它(服务器端)。这应该完全产生上面的 curl
请求给出的内容。
Then to use it (server side). This should produce exactly what the curl
request above gives out.
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
这篇关于如何使用Meteor.js对Dropbox API进行CURL调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!