svelte-fetchable

1.2.0 • Public • Published

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>

Package Sidebar

Install

npm i svelte-fetchable

Weekly Downloads

2

Version

1.2.0

License

MIT

Unpacked Size

6.84 kB

Total Files

12

Last publish

Collaborators

  • ujik