Using in browser: "TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation"
See original GitHub issueUsing the latest airtable.browser.js
and the latest jQuery
(same error with the old version referenced in test_files/index.html
), I get the following error:
In Chrome 86.0:
TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation
In Firefox 81.0:
TypeError: 'fetch' called on an object that does not implement interface Window.
Following code:
<html>
<head>
<script src="./vendor/jquery.js"></script>
<script src="./vendor/airtable.js"></script>
</head>
<body>
<script>
var Airtable = require('airtable');
var base = new Airtable({apiKey: 'API_KEY'}).base('BASE_ID');
base('TABLE_NAME').select({
maxRecords: 3,
view: "Grid view"
}).eachPage(function page(records, fetchNextPage) {
records.forEach(function(record) {
console.log('Retrieved', record.get('Name'));
});
fetchNextPage();
}, function done(err) {
if (err) { console.error(err); return; }
});
</script>
</body>
</html>
Issue Analytics
- State:
- Created 3 years ago
- Reactions:8
- Comments:9 (2 by maintainers)
Top Results From Across the Web
Failed to execute 'fetch' on 'Window': Illegal invocation - Stack ...
and performRequest throws this error ( Fetch TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation ). I've changed it to:
Read more >Failed to execute 'fetch' on 'Window': Illegal invocation · Issue ...
The script crashed with error TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation. After webkack it is looks: exports.
Read more >Failed to execute 'fetch' on 'Window': Illegal invocation ...
I trying to use fetch for calls to backend from react without libs like Axios. api.ts export const sendSuggestion = ((data: any): Promise<any> ......
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 >[SOLVED] Failed to execute 'fetch' on 'Window' - Moralis Forum
All of a sudden i keep getting Uncaught (in promise) TypeError: Failed to execute 'fetch' on 'Window': 1 argument required, ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@carderne here’s a simple workaround if you’re still stuck:
/node_modules/airtable/lib/fetch.js
On line 8, change
typeof window === 'undefined' ? node_fetch_1.default : fetch;
totypeof window === 'undefined' ? node_fetch_1.default : window.fetch.bind(window));
Or you can use my patch file until it’s fixed properly - use the below in conjunction with patch-package
/patches/airtable+0.10.0.patch
The change suggested by @rub1e is on line 313 in
airtable.browser.js
:https://github.com/Airtable/airtable.js/blob/96e2e80fe8d967c549c784fe9934596a94900a1a/build/airtable.browser.js#L313
Change it as suggested and it should work.