@booli/fetch-json

1.6.5 • Public • Published

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.

Readme

Keywords

none

Package Sidebar

Install

npm i @booli/fetch-json

Weekly Downloads

33

Version

1.6.5

License

MIT

Unpacked Size

9.01 kB

Total Files

7

Last publish

Collaborators

  • eddul
  • mrwest808
  • lers
  • marcusmalmberg
  • filipchr
  • mickehalen
  • linusvelin