React Native HTTP
raw JSON →React Native HTTP is a lightweight HTTP service wrapper for React Native applications, designed to simplify API interactions with built-in JWT token handling. Version 0.0.3 is the latest stable release, but the package appears to be in early development with sparse documentation. It provides an abstract base class HTTPService that supports GET, POST, PUT, DELETE methods with automatic token management (Authorization header, Bearer prefix, storage key). Key differentiators: minimal overhead, token lifecycle handled internally, supports per-request authorization skipping. However, it lacks TypeScript definitions, testing, and a clear roadmap; alternatives like axios or react-native-netinfo are more mature. The project is currently in maintenance mode with infrequent updates.
Common errors
error TypeError: _reactNativeHttp.default is not a function ↓
error Cannot find module 'react-native-http' ↓
error undefined is not an object (evaluating 'this.jwtService.setToken') ↓
Warnings
gotcha The package relies on react-native AsyncStorage for token storage; if AsyncStorage is removed in newer RN versions, token handling will fail. ↓
gotcha The skipAuthorization option must be passed as the third parameter to methods (e.g., this.get(path, null, {skipAuthorization: true})). Omitting it or placing it incorrectly will not skip authorization. ↓
breaking The package does not handle network errors gracefully; HTTP errors may reject the promise without detailed status codes. ↓
Install
npm install react-native-http yarn add react-native-http pnpm add react-native-http Imports
- HTTPService wrong
import HTTPService from 'react-native-http'correctimport { HTTPService } from 'react-native-http' - HTTPService wrong
const HTTPService = require('react-native-http')correctconst HTTPService = require('react-native-http').HTTPService - HTTPService
const { HTTPService } = require('react-native-http')
Quickstart
import { HTTPService } from 'react-native-http';
class MyAPI extends HTTPService {
getUsers() {
return this.get('users/');
}
createUser(data) {
return this.post('users/', data);
}
}
const api = new MyAPI('https://api.example.com');
api.getUsers().then(response => console.log(response)).catch(error => console.error(error));