We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Prismic.io
Prefetch
The text was updated successfully, but these errors were encountered:
Bron
Met de load functie kan je data vanuit de +page.js naar de +page.svelte sturen.
load
+page.js
+page.svelte
<script> export let data; console.log(data) const { products } = data; </script> <h1>Shop</h1> {#each products as product} <h2>{product.title}</h2> <p>{product.description}</p> {/each}
fetches
export const load = async ({ fetch }) => { // Async Fetch 1 const fetchProducts = async () => { const productRes = await fetch('https://dummyjson.com/products?limit=10'); const productData = await productRes.json(); return productData.products; }; // Async Fetch 2 const fetchUsers = async () => { const usersRes = await fetch('https://dummyjson.com/users?limit=10'); const usersData = await usersRes.json(); return usersData.users; }; return { products: fetchProducts(), users: fetchUsers() }; };
export const load = async ({ fetch }) => { // Fetch 1 const productRes = await fetch ('https://dummyjson.com/products?limit=10') const productData = await productRes.json() const products = productData.products // Fetch 2 const usersRes = await fetch ('https://dummyjson.com/users?limit=10') const usersData = await usersRes.json() const users = usersData.users return { products: products, users: users } }
+layout.svelte
Voeg data-sveltekit-prefetch toe aan een <a></a>
data-sveltekit-prefetch
<a></a>
<nav> <a href="/">Home</a> <a href="/shop" **data-sveltekit-prefetch**>Shop</a> <a href="/movies" **data-sveltekit-prefetch**>Movies</a> </nav>
Sorry, something went wrong.
No branches or pull requests
Prefetch
The text was updated successfully, but these errors were encountered: