# fetch-json-resource

> Fetch JSON resource with AbortController and error handling

Latest version **2.0.0** (published 2020-07-13) · ISC license · 0 weekly downloads

## Install

```sh
npm install fetch-json-resource
pnpm add fetch-json-resource
yarn add fetch-json-resource
bun add fetch-json-resource
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.0 |
| Published | 2020-07-13 |
| First published | 2019-11-11 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 8.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Mario Pizzinini |
| Maintainers | craftedsystems |
| Keywords | abortcontroller, fetch, javascript, json, timeout |

## Links

- npm: https://www.npmjs.com/package/fetch-json-resource
- Repository: https://github.com/craftedsystems/fetch-json-resource
- Homepage: https://github.com/craftedsystems/fetch-json-resource#readme
- Issues: https://github.com/craftedsystems/fetch-json-resource/issues
- npm.io page: https://npm.io/package/fetch-json-resource

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 2.0.0 (latest) — 2020-07-13
- 1.0.0 — 2020-03-24
- 0.6.3 — 2020-03-24
- 0.6.2 — 2020-01-10
- 0.6.1 — 2020-01-10
- 0.6.0 — 2020-01-08
- 0.5.3 — 2020-01-08
- 0.5.2 — 2020-01-08
- 0.5.0 — 2020-01-08
- 0.4.0 — 2020-01-08
- 0.3.1 — 2020-01-08
- 0.3.0 — 2020-01-08
- 0.2.2 — 2019-12-11
- 0.2.1 — 2019-11-12
- 0.2.0 — 2019-11-12
- … 1 more at https://npm.io/package/fetch-json-resource/versions

## README

# Fetch JSON Resource

<p>
  <a href="https://www.npmjs.com/package/fetch-json-resource">
    <img src="https://img.shields.io/npm/v/fetch-json-resource.svg" alt="npm version" >
  </a>
  <a href="https://github.com/craftedsystems/fetch-json-resource/blob/master/LICENSE">
    <img src="https://img.shields.io/npm/l/fetch-json-resource.svg" alt="license">
  </a>
  <a href="https://david-dm.org/craftedsystems/fetch-json-resource">
    <img src="https://david-dm.org/craftedsystems/fetch-json-resource/status.svg" alt="dependency status">
  </a>
  <a href="https://david-dm.org/craftedsystems/fetch-json-resource?type=dev">
    <img src="https://david-dm.org/craftedsystems/fetch-json-resource/dev-status.svg" alt="devDependencies status">
  </a>
</p>

[![Code Smells](https://sonarcloud.io/api/project_badges/measure?project=craftedsystems_fetch-json-resource&metric=code_smells)](https://sonarcloud.io/dashboard?id=craftedsystems_fetch-json-resource)
[![Maintainability Rating](https://sonarcloud.io/api/project_badges/measure?project=craftedsystems_fetch-json-resource&metric=sqale_rating)](https://sonarcloud.io/dashboard?id=craftedsystems_fetch-json-resource)
[![Reliability Rating](https://sonarcloud.io/api/project_badges/measure?project=craftedsystems_fetch-json-resource&metric=reliability_rating)](https://sonarcloud.io/dashboard?id=craftedsystems_fetch-json-resource)
[![Security Rating](https://sonarcloud.io/api/project_badges/measure?project=craftedsystems_fetch-json-resource&metric=security_rating)](https://sonarcloud.io/dashboard?id=craftedsystems_fetch-json-resource)
[![SonarCloud Bugs](https://sonarcloud.io/api/project_badges/measure?project=craftedsystems_fetch-json-resource&metric=bugs)](https://sonarcloud.io/component_measures/metric/reliability_rating/list?id=craftedsystems_fetch-json-resource)
[![Sonarcloud Status](https://sonarcloud.io/api/project_badges/measure?project=craftedsystems_fetch-json-resource&metric=alert_status)](https://sonarcloud.io/dashboard?id=craftedsystems_fetch-json-resource)
[![SonarCloud Vulnerabilities](https://sonarcloud.io/api/project_badges/measure?project=craftedsystems_fetch-json-resource&metric=vulnerabilities)](https://sonarcloud.io/component_measures/metric/security_rating/list?id=craftedsystems_fetch-json-resource)
[![Technical Debt](https://sonarcloud.io/api/project_badges/measure?project=craftedsystems_fetch-json-resource&metric=sqale_index)](https://sonarcloud.io/dashboard?id=craftedsystems_fetch-json-resource)

**Fetch JSON resource with AbortController and error handling.**

* no dependencies
* ~600 bytes gzipped

## Usage

```bash
# Install
npm i fetch-json-resource
```

```javascript
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.

```javascript
import fetchJsonResource from 'fetch-json-resource';

// Fetch options
const options = {};

// Abort after 5 seconds
const timeout = 5000;

fetchJsonResource('https://jsonplaceholder.typicode.com/todos/1', options, timeout)
  .then((json) => console.log(json))
  .catch((error) => console.log(error));
```

---
_Source: https://npm.io/package/fetch-json-resource · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
