1.1.1011 • Published 5 years ago
react-native-fetch-offline v1.1.1011
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
How to use
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;
}));
1.1.1011
5 years ago
1.1.1010
5 years ago
1.1.1009
5 years ago
1.1.1008
5 years ago
1.1.1007
5 years ago
1.1.1006
5 years ago
1.1.1005
5 years ago
1.1.1004
5 years ago
1.0.9
6 years ago
1.0.8
6 years ago
1.0.7
6 years ago
1.0.6
6 years ago
1.0.5
6 years ago
1.0.4
6 years ago
1.0.3
6 years ago
1.0.2
6 years ago
1.0.1
6 years ago
1.0.0
6 years ago