@gluons/react-native-fetch-with-timeout
TypeScript icon, indicating that this package has built-in type declarations

0.0.1 • Public • Published

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());
	}
})();

Package Sidebar

Install

npm i @gluons/react-native-fetch-with-timeout

Weekly Downloads

31

Version

0.0.1

License

MIT

Unpacked Size

5.82 kB

Total Files

5

Last publish

Collaborators

  • illuminator