cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Want to learn some quick and useful tips to make your day easier? Check out how Calvin uses Replay to get feedback from other teams at Dropbox here.

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Re: Get thumbnail with TypeScript

Re: Get thumbnail with TypeScript

bffy_smmmers
Explorer | Level 4

hey @Greg-DB - when i try that, i get the following:

 

TypeError: fetch is not a function
at /Users/rosiew/Repositories/backend/packages/rest/.webpack/service/handler.js:441710:16
at processTicksAndRejections (internal/process/task_queues.js:93:5)

12 Replies 12

Greg-DB
Dropbox Staff

I've moved your comment to its own thread since it's no longer related to the original thread.

 

How did you install the Dropbox library, and how are you setting up your client object?

bffy_smmmers
Explorer | Level 4

@Greg-DB Looks like this for the most part...

 

import { Dropbox, DropboxAuth, files } from 'dropbox_new';

import fetch from 'node-fetch';
 
 
export class DropboxApi {
private client: Dropbox;
private manager: Manager;
private constructor(client: Dropbox) {
this.client = client;
}
static async initialize({ accessToken, }: DropboxCredentials) {
return new DropboxApi(new Dropbox({ accessToken, fetch }));
}
 
 
 
async getThumbnail(path: any) {
return this.manager.execute(async () => {
const data: any = this.client
.filesGetThumbnail({ path })
.then((response: any) => {
console.log('got filesGetThumbnail response:');
console.log(response);
console.log('got thumbnail data:');
console.log(response.fileBlob);
})
.catch(error => {
console.log('got filesGetThumbnail error:');
console.log(error);
});

Greg-DB
Dropbox Staff

What version of 'dropbox' did you install, and how did you install it? Also, why is it 'dropbox_new' instead of just 'dropbox'?

 

You should ideally install the latest version, via npm, and then not manually pass in the fetch yourself. See here for a note on this: https://github.com/dropbox/dropbox-sdk-js/blob/main/UPGRADING.md#5-default-behavior-for-fetch 

bffy_smmmers
Explorer | Level 4

@Greg-DB the latest version 9.2.0. We're using a monorepo structure and instaling with yarn and so i had to add the package local to this repo by aliasing the package name, so it wouldnt keep pointing to the older versions of dropbox that are being used elsewhere in the root directory. 

Greg-DB
Dropbox Staff

Can you confirm node-fetch is also successfully installed? The 'dropbox' library lists it as a dependency (currently "^2.6.1"). And have you tried not passing in 'fetch' explicitly as noted?

bffy_smmmers
Explorer | Level 4

@Greg-DB it is!  Using:  "node-fetch": "2.6.1".

 

In the past when I've tried I've received a different error. and i just tried it again and got this: `TypeError: _this.fetch is not a function`. 

Greg-DB
Dropbox Staff

Thanks for checking that. It's not clear why this is failing. Can you inspect what your 'fetch' or '_this.fetch' is in fact, if not a function?

bffy_smmmers
Explorer | Level 4

fetch is either a Function or undefined! @Greg-DB 

bffy_smmmers
Explorer | Level 4

Here is an error message to add more context - i dont understanad what "dropbox_fetch" is. When i dont include fetch in the constructor I still receive an error regarding fetch. 

 

21-03-17T20:33:29.417-04:00

Copy
2021-03-18T00:33:29.417Z 74c3d3e2-e0a3-44e1-b49b-253580120ebd INFO TypeError: dropbox_fetch is not a function
at /var/task/handler.js:453612:16
at processTicksAndRejections (internal/process/task_queues.js:97:5)
2021-03-18T00:33:29.417Z 74c3d3e2-e0a3-44e1-b49b-253580120ebd INFO TypeError: dropbox_fetch is not a function at /var/task/handler.js:453612:16 at processTicksAndRejections (internal/process/task_queues.js:97:5)

Need more support?