Wretch

A tiny (~ 2Kb g-zipped) wrapper built around fetch with an intuitive syntax.

Immutable
Intuitive
Chainable
Isomorphic
Modular

Wretch does not mutate its internal state.
Each function returns a copy of the original object.

Wretch's syntax is readable and concise.
And it contains typescript definition files for autocompletion.

All methods are 100% chainable.
Because a.b().c() is prettier than var z = a; z.b(); z.c().

Wretch is compatible with browsers and node.js.
And you can use any polyfill you like!

Use Addons to add new methods and capabilities.
Use Middlewares to intercept requests and fully customize Wretch behaviour.

npm i wretch
<script src="https://unpkg.com/wretch"></script>

Usage

import wretch from "wretch"
wretch()
  .helperMethods() //.url, .options, .headers ...
  .bodyType()      // .json, .formData, .formUrl ...
  .httpMethod()    // .get, .post, .put ...
  .errorCatchers() // .notFound, .unauthorized ...
  .responseType()  // .json, .blob ...
  .then/catch()
// Like aborting a request