0.0.1 • Published 4 years ago

@gluons/react-native-fetch-with-timeout v0.0.1

Weekly downloads
-
License
MIT
Repository
gitlab
Last release
4 years ago

React Native Fetch with Timeout

Personal usage only. No further support.

Fetch with timeout for React Native.

Installation

npm install -S @gluons/react-native-fetch-with-timeout

or

yarn add @gluons/react-native-fetch-with-timeout

Usage

import { Alert } from 'react-native';
import fetchWithTimeout from '@gluons/react-native-fetch-with-timeout';

(async () => {
	try {
		const res = await fetchWithTimeout(
			'https://<request-url>',
			{},
			{
				timeout: 5000 // 5 seconds
			}
		)
	} catch (err) {
		// Thrown "Request Timeout" error after 5 seconds
		Alert.alert('Error', err.toString());
	}
})();
0.0.1

4 years ago