According to the Nuxt documentation these methods are used to pre-fill store before page is served.
In what cases should I use fetch
and in what cases - nuxtServerInit
?
I think of nuxtServerInit
as the place to go if I need to make requests that prefetch options that are used in all the App, languages, configaration values, input options, etc...
fetch
&asyncData
instead fire both on the client and server once that pages gets rendered.
That means that fetch
& asyncData
will fire every time the component is matched by the router and nuxtServerInit
only once, at the beginning, on the server, and never again.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With