Search code examples
node.jsnpmdropbox

Global fetch is deprecated and will be unsupported in a future version. npm DropBox issue


I was getting the following warning

Global fetch is deprecated and will be unsupported in a future version. Please pass fetch function as option when instantiating dropbox instance: new Dropbox({fetch})

The warning was produced by the following code

import Dropbox  from 'dropbox'
var dbx = new Dropbox.Dropbox({ accessToken: dropBoxAccessToken });
dbx.filesListFolder({path: ''})

There is was not a great post on this at the time of this edit so I am posting in the hopes that it can save someone some time.


Solution

  • The solution is to pass fetch in as follows:

    var dbx = new Dropbox.Dropbox({ fetch:fetch, accessToken: dropBoxAccessToken });
    

    No more warning or depreciation issues