Skip to content

Instantly share code, notes, and snippets.

@penalosa
Created March 23, 2021 13:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save penalosa/61443cd29eb18f262fee795b4b2fabd5 to your computer and use it in GitHub Desktop.
Save penalosa/61443cd29eb18f262fee795b4b2fabd5 to your computer and use it in GitHub Desktop.
Data fetching in Svelte
<script>
import { onMount } from "svelte"
let data
onMount(() => {
fetch("https://example.com/my/api")
.then(r => r.json())
.then(j => data = j)
}
</script>
{data}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment