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

回眸只為那壹抹淺笑 提交于 2019-12-01 01:58:51

问题


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

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>"

I wish to get list of files in the directory but for now I am stuck with the Authentical Token.


回答1:


You can use the HTTP package you mentioned

Add it with

meteor add http

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


来源:https://stackoverflow.com/questions/29117689/how-to-make-a-curl-call-to-dropbox-api-using-meteor-js

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!