Last active
January 30, 2022 21:25
-
-
Save SergioJuniorCE/9ea7e3d1751b99e1aaf32ee299e4e69c to your computer and use it in GitHub Desktop.
load function sveltekit
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script context="module"> | |
export async function load({ page, params, fetch, session, stuff }) { | |
const slug = page.params.slug; | |
const url = `http://localhost:1337/categories/${slug}`; | |
const res = await fetch(url); | |
const category = await res.json(); | |
return { | |
props: { | |
category | |
} | |
}; | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment