简体   繁体   中英

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

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM