question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

dbx.filesListFolder - TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation

See original GitHub issue

Hi,

I am having the same issue as This bug that was recently closed.

I have installed the dropbox SDK in npm (in package.json: “dropbox”: “^7.3.0”) for use in react (browser, not using node).

Running this code:

componentDidMount() { this.listRecordings(); }

listRecordings() {
	let dbx = new Dropbox({
		accessToken: getAccessTokenFromUrl()
	});

	dbx.filesListFolder({ path: '' })
		.then(res => console.log(res))
		.catch(function(error) {
			console.error(error);
		});

Outputs this error in the console:

TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation at Dropbox-sdk.min.js:1

I am able to successfully call and walk through authentication process with: var dbx = new Dropbox({ clientId: CLIENT_ID }); dbx.auth.getAuthenticationUrl('http://localhost:3000/') in another react component and parse the token which appears in the URL successfully with getAccessTokenFromUrl().

Not sure why I am unable to list folders – I think there’s some issue with accessing “window.fetch” but unsure where it comes from.

I have tried reverting to versions 6.0.2 and still get the same error.

Any response on this bug would be greatly appreciated – it looks quite similar to the one you have recently squashed! @greg-db @rogebrd

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
rogebrdcommented, Nov 2, 2020

Hello Josh,

I am not super familiar with how fetch works in a React app so bear with me but could you try adding fetch: fetch as a parameter to the constructor?

0reactions
jhell96commented, Jan 18, 2021

I decided to just hit the Dropbox API myself because it was being really buggy. In case this might help anyone, try something like this:

	let url = 'https://content.dropboxapi.com/2/files/download';
	let options = {
		method: 'POST',
		headers: {
		  "Authorization": `Bearer ${access_token}`,
		  "Dropbox-API-Arg": JSON.stringify({ "path": path })
		}
	};
	let fetchDataFromApi = async (url, args) => {
		let response = await fetch(url, args);
		let result = await response.blob();
		return result
	}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Failed to execute 'fetch' on 'Window': Illegal invocation - ...
and performRequest throws this error ( Fetch TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation ). I've changed it to:
Read more >
[SOLVED] Failed to execute 'fetch' on 'Window'
All of a sudden i keep getting Uncaught (in promise) TypeError: Failed to execute 'fetch' on 'Window': 1 argument required, ...
Read more >
Failed to execute 'fetch' on 'Window': Illegal invocation
Hi there,. I'm attempting to integrate my airtable database api into a React project. I installed airtable using 'npm install airtable'.
Read more >
Failed to execute 'fetch' on 'Window': Illegal invocation – ...
Javascript – Fetch TypeError: Failed to execute 'fetch' on 'Window': ... I trying to use fetch for calls to backend from react without...
Read more >
typeerror: failed to execute 'fetch' on 'window': request ... - 腾讯云
window.fetch) { try { require('whatwg-fetch') this.originFetch = window.fetch; // fixed: Fetch TypeError: Fa.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found