0

I am trying a dropbox sample code found here.

This is the code that I am using -

var dropbox = require("dropbox")

console.log("dropbox:",dropbox)
console.log("dropbox.Client:",dropbox.Client)

var client = new dropbox.Client({
    key: "my-key",
    secret: "my-secret"
});


client.authDriver(new dropbox.AuthDriver.NodeServer(8191));

client.authenticate(function(error, client) {
  if (error) {
    console.log('error')
    return
  }

   console.log("worked")

});

But I am getting this error output -

Dropbox: function (options) {
  DropboxBase.call(this, options);
}
Dropbox.Client: undefined
/Users/11126/code/node/idea/ideadbapi/idea_bckp/bckp.js:6
var client = new Dropbox.Client({
             ^
TypeError: undefined is not a function
    at Object.<anonymous> (/Users/11126/code/node/idea/ideadbapi/idea_bckp/bckp.js:6:14)
    at Module._compile (module.js:460:26)
    at Object.Module._extensions..js (module.js:478:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Function.Module.runMain (module.js:501:10)
    at startup (node.js:129:16)
    at node.js:814:3

Can anyone please help whats going wrong? Why is dropbox.Client undefined?

Pavan Kishore
  • 91
  • 2
  • 9

1 Answers1

2

You're trying to use the deprecated/un-maintained dropbox-js library, but it looks like you actually installed the newer dropbox-sdk-js library.

The latter is preferred anyway, so you should follow that documentation:

https://github.com/dropbox/dropbox-sdk-js#quickstart

Greg
  • 16,359
  • 2
  • 34
  • 44