Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

this.fetch is not a function error received #1132

Open
soybeins opened this issue Jan 11, 2024 · 3 comments
Open

this.fetch is not a function error received #1132

soybeins opened this issue Jan 11, 2024 · 3 comments
Labels

Comments

@soybeins
Copy link

soybeins commented Jan 11, 2024

The bug occurs upon calling a next.js api which uses the filesUpload() or filesCreateFolderV2() function. It will automatically close the request returning this.fetch is not a function error.

Regarding when the error occurs during the api call, it seems to occur within the instance/import itself since it is the only thing logged during the request which means it did not proceed into the middlewares/services.

The bug seems to only occur on the deployed application. It cannot be replicated in local. We also have updated the environment variables (Client Secret, Refresh Token, Access Token) but to no avail.

Dropbox Instance:

import { Dropbox } from 'dropbox';

const dbx = new Dropbox({
  refreshToken: process.env.DROPBOX_REFRESH_TOKEN,
  clientId: process.env.DROPBOX_CLIENT_ID,
  clientSecret: process.env.DROPBOX_CLIENT_SECRET,
});

Screenshots:
image
image

Versions

  • What version of the SDK are you using? 10.34.0
  • What version of the language are you using? Node 18.x.0 , Next.js 14.0.4
  • Are you using Javascript or Typescript? Javascript
  • What platform are you using? (if applicable) Vercel
@soybeins soybeins added the bug label Jan 11, 2024
@greg-db
Copy link
Contributor

greg-db commented Jan 11, 2024

The Dropbox JavaScript SDK uses this.fetch to perform the network requests to the Dropbox API servers for the Dropbox API calls. In a Node environment, that is supposed to get set from node-fetch. Is there some reason that may not be working (for instance, is node-fetch not properly installed?) or may be overwritten by something else in your deployed application?

@soybeins
Copy link
Author

It maybe overwritten by something else but not sure. In the meantime, I explicitly imported fetch and passed it to the dropbox instance. Works

import { Dropbox } from 'dropbox';
import fetch from 'fetch';

const dbx = new Dropbox({
  refreshToken: process.env.DROPBOX_REFRESH_TOKEN,
  clientId: process.env.DROPBOX_CLIENT_ID,
  clientSecret: process.env.DROPBOX_CLIENT_SECRET,
  fetch
});

@greg-db
Copy link
Contributor

greg-db commented Jan 22, 2024

Thanks for following up. I'm glad to hear you got this working.

It sounds like this is related to something in that particular environment, but if you find there's something in the Dropbox SDK itself that needs to be addressed, please let us know so we can look into it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants