@booli/fetch-json

Fetch wrapper for json resorces

Stats

stars 🌟issues ⚠️updated 🛠created 🐣size 🏋️‍♀️
@booli/fetch-json
Minified + gzip package size for @booli/fetch-json in KB

Readme

Fetch Json

Wrapper around fetch to request json and geo json resources, including some general error handling.

Note that 204 responses will return an empty object {} instead of a body with no content, so subsequent json parsing does not fail.

Required polyfills

  • fetch
  • Object.assign
  • Promise (indirectly needed as fetch polyfills require it)

Motivation

Most fetch requests expect json response and setting up request headers,checking response headers and handling http errors involve some boilerplate, which is abstracted away by this package. Note that unlike native fetch this wrapper will reject the returned promise if the response has an error status code.

If you find any bugs or have a feature request, please open an issue on github!

The npm package download data comes from npm's download counts api and package details come from npms.io.