google-api-javascript-client throw "Uncaught ReferenceError: window is not defined" in Remix CF page
I am trying to use google-api-javascript-client (recommended by google) in my Remix CF page project. Sample code is https://github.com/google/google-api-javascript-client/blob/master/docs/start.md#option-2-use-gapiclientrequest. However, it failed:
✘ [ERROR] service core:user:myproject Uncaught ReferenceError: window is not defined
at null.<anonymous> (functionsWorker-0.15113220025986496.js:63854:19)
at null.<anonymous> (functionsWorker-0.15113220025986496.js:64327:4)
✘ [ERROR] MiniflareCoreError [ERR_RUNTIME_FAILURE]: The Workers runtime failed to start. There is likely additional logging output above.
Any idea? Appreciate very much!
GitHub
google-api-javascript-client/docs/start.md at master · google/googl...
Google APIs Client Library for browser JavaScript, aka gapi. - google/google-api-javascript-client
2 Replies
google-api-javascript-client
is designed to run on the client, not the server, so is looking for things like window
. I'm not sure if they publish a version that's compatible with Cloudflare Workers via fetch
- you might have better luck calling the APIs you need directly via fetch
instead of their client.Thanks very much!