Hi,
I’m trying to figure out what are the best practices to fetch pages. At the moment I am fetching everything in beforeSSR but that makes the first load of the website really slow. Here is what I have
actions: {
theme: {
beforeSSR: async ({ state, actions }) => {
await Promise.all([
await actions.source.fetch("theme-globalgoals-settings"),
await actions.source.fetch(`/menu/${state.theme.mainMenu}/`),
await actions.source.fetch(`/menu/${state.theme.shortcutsMenu}/`),
await actions.source.fetch(`/menu/${state.theme.footerMenu}/`),
await actions.source.fetch(`/goals/`),
await actions.source.fetch(`/take-action/`),
await actions.source.fetch(`/whats-happening/`),
await actions.source.fetch(`/category/news/`),
await actions.source.fetch(`/category/campaigns/`),
await actions.source.fetch(`/resources/`),
await actions.source.fetch(`/spread-the-word/`),
await actions.source.fetch(`/languages/`),
await actions.source.fetch(`/fr/`),
await actions.source.fetch(`/sv/`),
await actions.source.fetch(`/es/`),
await actions.source.fetch(`/zh/`),
await actions.source.fetch(`/ja/`),
await actions.source.fetch(`/ru/`),
await actions.source.fetch(`/`),
Object.values(resourcesCategories).map(category => actions.source.fetch(`/resources_categories/${category}/`))
]);
},
If I remove them and navigate between pages, I get the Failed to fetch error on every page.
What is the best way to fetch content?
Thanks