3.0.0 • Published 5 months ago

setch v3.0.0

Weekly downloads
-
License
ISC
Repository
github
Last release
5 months ago

Simplest fETCH wrapper I could come up with to reduce boilerplate code when using fetch on a daily basis while keeping as much compatibility with standard as possible

features

  • creating setch functions with default options
  • flexible status code checks with proper errors
  • aliases to common content-type strings

install

npm i setch

usage

// basics, see docs for details
import { setch, makeSetch, mime } from 'setch'

// capture common parameters for reuse
const setchMyApi = makeSetch(
  baseUrlString, // final url will be baseUrlString + urlString
  { headers: { accept: mime.json } }, // will be merged with options, headers too
  200, // expected status, will throw if it isn't, can be overridden and flexible, see docs
)
// same as setch, but uses captured parameters too
const json = await setchMyApi(urlString, options).then(r => r.json())

docs

generated typedoc

but there's not much to it really, have a look at source if you're curious :^)

3.0.0

5 months ago

2.2.1

6 months ago

2.0.3

10 months ago

2.1.0

10 months ago

2.0.2

2 years ago

2.0.1

2 years ago

2.0.0

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.0

2 years ago

1.0.1

2 years ago