A convenience wrapper around the fetch API
yarn add @ianwalter/http
import { http } from '@ianwalter/http'
// Add a new header to the global http instance.
http.options.headers = { 'csrf-token': 'abc123' }
// Send a POST request with some data.
const response = await http.post('/api/thing', { body: { complete: true } })
http.after = (url, init, response) => ({
...response,
ok: false,
status: 401,
statusText: 'Unauthorized'
})
Apache 2.0 with Commons Clause - See LICENSE
Created by Ian Walter