Skip to content

Instantly share code, notes, and snippets.

@penalosa
Created March 23, 2021 13:41
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/78e57c8612b7a273e106c316127167f6 to your computer and use it in GitHub Desktop.
Save penalosa/78e57c8612b7a273e106c316127167f6 to your computer and use it in GitHub Desktop.
<script>
import {Fetch} from "svelte-data-loading"
</script>
<Fetch
base="https://example.com" // optional, will be prepended to all API `load` paths. Special case of `transform`
headers={headers => ({...headers, ...headersToAdd})} // Add additional headers for e.g. auth. Special case of `transform`
transform={({method, url, headers, body}) => ({method, url, headers, body})} // Modify a request before it's made
defautLoading={Component} // display if the `loading` slot isn't provided
defaultError={Component} // display if the `error` slot isn't provided
on:error={response => {}} // handle things like auth errors, which might require a navigation
>
<YourAppHere/>
</Fetch>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment