nuxt-graphql-request icon indicating copy to clipboard operation
nuxt-graphql-request copied to clipboard

How to get requests once with nuxtServerInit on nuxt generate

Open niklasfjeldberg opened this issue 4 years ago • 2 comments
trafficstars

I know that cache is not handled by this project, but do anyone happen to have a suggestion on how this could be accomplished?

I fetch the data with nuxtServerInit in store/index.js but this will run every time i refresh the page, or many times when the command nuxt generate runs. This is apparently expected behavior for nuxtServerInit and there is extensions you could use to get around this if you use axios.

So is there any similar solution, or any other way that i could do this without fetching data multiply times?

niklasfjeldberg avatar May 01 '21 12:05 niklasfjeldberg

This is something I’d love to figure out to. A “nuxtGenerateInit” function.

I suspect using a plugin with and the generate hook is the way to go, but I’m not sure.

drewbaker avatar May 01 '21 13:05 drewbaker

I made this module to solve this: https://github.com/funkhaus/fuxt/tree/master/modules/populate

drewbaker avatar Oct 14 '21 16:10 drewbaker