|
Hey everyone - I have an optimization question. I'm trying to fetch an API response at Currently I'm calling the API in api.getSingle('navigation', {}).then((document) => {
// Set `navigation` store
});Then using that <script lang="ts">
import navigationItems from '$lib/stores/navigation';
</script>
<nav>
{#each navigationItems as item}
<!-- Items in HTML here -->
{/each}
</nav>Right now that only pre-renders <nav>
</nav>And then it fetches the API request client-side during hydration. How do I get the component to be included in the pre-render with the |
Answered by
benaltair
Nov 10, 2021
Replies: 1 comment
|
As suggested by PM on Discord the API call should happen within |
0 replies
Answer selected by
benaltair
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
As suggested by PM on Discord the API call should happen within
load()for the__layoutfile to be included in the pre-rendered files. I've now removed the store altogether, and passed down a prop from__layoutto theHeadercomponent with the appropriate data.