0.3.0 • Published 6 months ago
react-native-native-fetch v0.3.0
react-native-native-fetch
Native HTTP request api
Installation
npm install react-native-native-fetch
Android
- Add following permissions into
android/src/main/AndroidManifest.xml
<uses-permission android:name="android.permission.INTERNET" />
- Also set
usesCleartextTraffic
totrue
to enablehttp
(nonhttps
) requests as below.
<application
android:usesCleartextTraffic="true"
/>
Usage
import { nativeFetch } from 'react-native-native-fetch';
// ...
const payload = { arg1: 'Hello', arg2: 'World' };
const result = await nativeFetch('http://some-url.com', {
body: JSON.stringify(payload),
contentType: 'JSON',
method: 'POST',
}: INativeFetchOptions): Promise<any>;
// types
interface INativeFetchOptions {
body?: string;
contentType?: 'JSON' | 'PLAIN' | 'MULTIPART';
method: 'GET' | 'POST' | 'PUT' | 'DELETE';
}
TODO
- Android support
- iOS support
Contributing
See the contributing guide to learn how to contribute to the repository and the development workflow.
License
MIT
Created by Alauddin Ansari (alauddinx27@gmail.com)