Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/webermarci/svelte-store-fetcher

A svelte library that helps with fetching and caching.
https://github.com/webermarci/svelte-store-fetcher

cache fetch svelte svelte-store typescript

Last synced: 10 days ago
JSON representation

A svelte library that helps with fetching and caching.

Awesome Lists containing this project

README

        

# Svelte Store Fetcher

[![npm version](https://badge.fury.io/js/svelte-store-fetcher.svg)](https://badge.fury.io/js/svelte-store-fetcher)

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

It's based on [Tim's original implementation](https://github.com/cstrnt/modern-fetch-with-svelte).

## Usage
```bash
yarn add -D svelte-store-fetcher

npm install --save-dev svelte-store-fetcher
```

```html

import { get } from "svelte-store-fetcher";
const response = get("https://rickandmortyapi.com/api/character/1", 5000);

{#await $response}

Loading


{:then data}
{JSON.stringify(data)}
{:catch}

Error


{/await}

```