You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@tolstenko thanks for this comment. Yes, the setup for fetch is pretty rough. It does work in the browser but it feels a bit weird... and I'm not sure if it's the generator's responsibility to provide a polyfill.
I have currently setup the template with a template hook so you can customise it... it's not super nice but possible.
In your config file you need to add:
custom: ./custom
And then in that custom folder, create a hooks folder and put a file called runtimeImports.hbs and put a single line in that:
exportconstdefaultFetch=fetch;
This is using the custom templates capability.
I'm not sure whether this is an answer to this issue... I have setup the generator so you can customise this...
Maybe it would be better to put in some auto detection of the environment by default? In JavaScript we could check to see if there's a fetch global and use that and then check if there's a window.fetch and use that, or not have a default and then the user has to provide fetch when they create the API.
Hi!
On Nextjs, SSR only allows fetch API and doesn't allow window.
The generated file runtime.ts contains:
but I constantly edit to be like this:
Today, I just created a script to do that for me, and this change would help react-ssr people like me. :-)
So please create a new generator or add a configuration to do that for us :)
BTW, Thank you for your excellent work!
The text was updated successfully, but these errors were encountered: