Skip to content

Latest commit

 

History

History
31 lines (24 loc) · 747 Bytes

README.md

File metadata and controls

31 lines (24 loc) · 747 Bytes

Svelte Store Fetcher

npm version

This package helps you with fetching and caching responses with rarely showing the loading state.

It's based on Tim's original implementation.

Usage

yarn add -D svelte-store-fetcher

npm install --save-dev svelte-store-fetcher
<script>
  import { get } from "svelte-store-fetcher";
  const response = get("https://rickandmortyapi.com/api/character/1", 5000);
</script>

<main>
  {#await $response}
    <h1>Loading</h1>
  {:then data}
    <code>{JSON.stringify(data)}</code>
  {:catch}
    <h1>Error</h1>
  {/await}
</main>