2.2.0 • Published 1 year ago

@klw/fetch v2.2.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

fetch

A thin wrapper around the fetch api

  • normalizes response.ok
  • returns the response body as JSON
  • uses the localstorage item token to authenticate with the api

Usage

yarn add @klw/fetch
import { get, post, put, delete } from "@klw/fetch";

const resp = await get(`/api/users`);
if (resp.ok) {
    ...
}

const resp = await post(`/api/users/login`, { email, password });
if (resp.ok) {
    ...
}

const resp = await put(`/api/users/u_id`, { firstName, lastName });
if (resp.ok) {
    ...
}

const resp = await del(`/api/users/u_id`);
if (resp.ok) {
    ...
}

Options are available (not documented at the moment).

2.2.0

1 year ago

2.1.0

1 year ago

2.0.0

1 year ago

1.2.2

3 years ago

1.2.1

3 years ago

1.1.0

3 years ago

1.0.0

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago