Created
March 23, 2021 13:41
-
-
Save penalosa/78e57c8612b7a273e106c316127167f6 to your computer and use it in GitHub Desktop.
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> | |
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