smallfetch
Smallfetch is a pre configured fetch object ready to interact with a Rest API
Tiny implementation of 200B with no dependencies.
- It sets headers by default to 'application/json'.
- It stringify object payload and pass it as body content for PUT/POST/PATCH.
- It parses server response to JSON.
- It throws a cachable error when the response is not in the range 200-299.
Installation
npm install smallfetch
;
Usage
Get - Search
let books = await ;console;
#### Post - Create
;
Put - Update
;
To avoid throwing errors (for parallel request) pass false at the end of the request.
Promiseall;
All request will execute without failing. If the request fail an object with the request data will be returned but no exception will be thrown.