Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 977
Vaibhav Kanwal Avatar asked Mar 18 '15 08:03

Vaibhav Kanwal


1 Answers

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
like image 146
Tarang Avatar answered Nov 14 '22 21:11

Tarang