@blackbox-vision/react-native-http-client
TypeScript icon, indicating that this package has built-in type declarations

0.0.1 • Public • Published

RN Http Client License: MIT

This package let us use Axios in a simpler way to handle requests.

Install

You can install this library via NPM or YARN.

NPM

npm i @blackbox-vision/react-native-http-client

YARN

yarn add @blackbox-vision/react-native-http-client

Use case

This library let us handle requests in a simpler way.

Usage

  1. Create a http-client.ts and initialize your HttpClient:
// utils/http-client.ts
import Env from "react-native-config";
import { HttpClient } from "@blackbox-vision/react-native-http-client";

import {
  YourCustomInterceptor,
  ResponseToCamelCase,
} from "./custom-interceptors";

HttpClient.setTimeout(45000);
HttpClient.setBaseURL(Env.BASE_URL);
HttpClient.setHeaders({
  "Content-Type": "application/json",
});
HttpClient.setRequestInterceptors(YourCustomInterceptor);
HttpClient.setResponseInterceptors(ResponseToCamelCase);

export default HttpClient;
  1. Invoke in your service and perform requests:
// services/user.ts
import HttpClient from "utils/http-client";

export const getAll = async (): Promise<User[]> => {
  return await HttpClient.get<User[]>(`/users`);
};

Issues

Please, open an issue following one of the issues templates. We will do our best to fix them.

Contributing

If you want to contribute to this project see contributing for more information.

License

Distributed under the MIT license. See LICENSE for more information.

/@blackbox-vision/react-native-http-client/

    Package Sidebar

    Install

    npm i @blackbox-vision/react-native-http-client

    Weekly Downloads

    2

    Version

    0.0.1

    License

    MIT

    Unpacked Size

    17.5 kB

    Total Files

    8

    Last publish

    Collaborators

    • jonatansalas
    • manutuero