Open jaymakes11 opened 3 years ago
The runtime for Cloudflare Workers is not browser
or node
, which I suspect is the issue here. It uses the V8 JS engine directly (https://developers.cloudflare.com/workers/runtime-apis/web-standards). This means it doesn't have access to some runtime APIs that are available in Node.
Hoping this is not a blocker for being able to run Airtable in Cloudflare Workers.
Posted this in the Cloudflare forum. Findings (from here https://community.cloudflare.com/t/cant-use-airtable-from-worker/232590/2):
The problem looks to be that it’s trying to grab window.fetch, which isn’t possible within a service worker, and then defaulting to nodeFetch if that’s not available.
If that is, indeed, the case, this seems similar to the previous problems FaunaDB's JS driver was having in Cloudflare Workers. There's already a fetch
method available to workers, so the solution they took was to allow passing in a custom fetch handler when initiating the client. See here: https://github.com/fauna/faunadb-js/issues/207
Perhaps the same approach would work here?
I ended up using airtable-dnd, an "Unofficial Airtable API client for Node.js ported from airtable-deno" as it internally uses fetch
and assumes it exists. API is quite similar to @Airtable/airtable.js.
When trying to use via a Cloudflare Worker (https://workers.cloudflare.com/), I get: