# react-native-fetch-offline

> Returns fetch object with cached data if user is offline

Latest version **1.1.1011** (published 2019-04-05) · ISC license · 0 weekly downloads

## Install

```sh
npm install react-native-fetch-offline
pnpm add react-native-fetch-offline
yarn add react-native-fetch-offline
bun add react-native-fetch-offline
```

## 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 | 1.1.1011 |
| Published | 2019-04-05 |
| First published | 2018-07-23 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 7.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Hardeep Singh |
| Maintainers | hardeepsingh |
| Keywords | offline, fetch, reachability, fetch offline, react native fetch, react native fetch offline, network |

## Links

- npm: https://www.npmjs.com/package/react-native-fetch-offline
- Repository: https://github.com/hardeepamritsar/react-native-fetch-offline
- Homepage: https://github.com/hardeepamritsar/react-native-fetch-offline#readme
- Issues: https://github.com/hardeepamritsar/react-native-fetch-offline/issues
- npm.io page: https://npm.io/package/react-native-fetch-offline

## Dependencies (3)

- [lodash](https://npm.io/package/lodash.md) ^4.17.10
- [object-hash](https://npm.io/package/object-hash.md) ^1.3.0
- [react-native-internet-reachability](https://npm.io/package/react-native-internet-reachability.md) ^1.0.7

## Alternatives

- [gamedig](https://npm.io/package/gamedig.md) — 29.3K weekly downloads
- [join-monster](https://npm.io/package/join-monster.md) — 12.8K weekly downloads
- [masked](https://npm.io/package/masked.md) — 5.5K weekly downloads
- [@comunica/actor-query-process-explain-logical](https://npm.io/package/@comunica/actor-query-process-explain-logical.md) — 4.7K weekly downloads
- [@veracity/vui](https://npm.io/package/@veracity/vui.md) — 4.6K weekly downloads

## Recent versions

- 1.1.1011 (latest) — 2019-04-05
- 1.1.1010 — 2019-04-05
- 1.1.1009 — 2019-04-05
- 1.1.1008 — 2019-04-05
- 1.1.1007 — 2019-04-05
- 1.1.1006 — 2019-02-27
- 1.1.1005 — 2019-02-26
- 1.1.1004 — 2019-02-26
- 1.0.9 — 2018-08-16
- 1.0.8 — 2018-08-16
- 1.0.7 — 2018-08-16
- 1.0.6 — 2018-08-16
- 1.0.5 — 2018-08-16
- 1.0.4 — 2018-08-07
- 1.0.3 — 2018-08-07
- … 3 more at https://npm.io/package/react-native-fetch-offline/versions

## README

<p align="center"><a href="https://travis-ci.org/hardeepamritsar/react-native-fetch-offline"><img src="https://api.travis-ci.org/hardeepamritsar/react-native-fetch-offline.svg?branch=master"/></a></p>

# react-native-fetch-offline
Returns fetch object with cached data if user is offline

## Installation

```
npm install --save react-native-fetch-offline # with npm
yarn add react-native-fetch-offline # with yarn
```

Link react-native-internet-reachability
```
react-native link react-native-internet-reachability
```

## How it works

<p align="center"><a href="https://i.imgur.com/X5X9FFq.png"><img src="https://i.imgur.com/X5X9FFq.png"/></a></p>


## How to use
```javascript
import FetchOffline, { cacheReponse } from 'react-native-fetch-offline';

  const requestOptions = {
    method: 'GET',
    offline: {
      defaultResponse: {
        data: {
          myKey: 'myValue',
        }
      },
    },
  };


FetchOffline('http://www.domain.com/api', requestOptions)
    .catch(err => get(err, 'message', 'Default error message'))
    .then(response => response.json()
      .then((body) => {
        cacheReponse(requestOptions.url, fetchOptions, body); // if you want to cache response (to be returened for future calls while being offline)
        return body;
      }));
```

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