svelte fetchable

npm i svelte-fetchable
<script>
  import fetchable from 'svelte-fetchable'

  const [resultFetch, loadingFetch] = fetchable.post('https://jsonplaceholder.typicode.com/posts')
</script>

<main>
 <div>
    {#if $loadingFetch}
      <span>loading...</span>
    {:else}
      <span>result: {JSON.stringify($resultFetch)}</span>
    {/if}

    <br />
    <button on:click={() => resultFetch.fetch({ username: 'John Doe' })}>Fetch</button>
    <br />
    <button on:click={resultFetch.abort}>Abort</button>
  </div>
</main>

Top categories

svelte logo

Need a Svelte website built?

Hire a professional Svelte developer today.
Loading Svelte Themes