fetch-json-resource
2.0.0 • Public • Published Fetch JSON Resource
Fetch JSON resource with AbortController and error handling.
- no dependencies
- ~600 bytes gzipped
Usage
npm i fetch-json-resource
import fetchJsonResource from 'fetch-json-resource';
fetchJsonResource('https://jsonplaceholder.typicode.com/todos/1')
.then((json) => console.log(json))
.catch((error) => console.log(error));
Options
You can add additional fetch options and/or a custom timeout value.
import fetchJsonResource from 'fetch-json-resource';
const options = {};
const timeout = 5000;
fetchJsonResource('https://jsonplaceholder.typicode.com/todos/1', options, timeout)
.then((json) => console.log(json))
.catch((error) => console.log(error));
Package Sidebar
Install
npm i fetch-json-resource
Weekly Downloads