Skip to content

ianwalter/http

Repository files navigation

@ianwalter/http

A convenience wrapper around the fetch API

npm page

Installation

yarn add @ianwalter/http

Usage

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 } })

Intercepting requests and responses

http.after = (url, init, response) => ({
  ...response,
  ok: false,
  status: 401,
  statusText: 'Unauthorized'
})

License

Apache 2.0 with Commons Clause - See LICENSE

 

Created by Ian Walter

About

A convenience wrapper around the fetch API

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •