Coder Social home page Coder Social logo

pankaz / react-native-http-client Goto Github PK

View Code? Open in Web Editor NEW

This project forked from freshheads/react-native-http-client

0.0 0.0 0.0 953 KB

License: MIT License

JavaScript 7.20% Ruby 14.38% C 0.40% Objective-C 10.47% Java 28.99% Kotlin 14.13% TypeScript 8.54% Objective-C++ 4.49% Swift 11.41%

react-native-http-client's Introduction

React-Native-Http-Client

A Native HTTP Client for React Native projects.

For iOS, it utilizes URLRequest and URLSession. For Android, it deploys OkHttp.

The rationale behind this package is to provide a straightforward HTTP client that functions seamlessly across both platforms and is user-friendly. Our objective was to establish a connection with a webservice hosted on an embedded device. However, we encountered a persistent 401 error. Interestingly, the connection was successful via Postman.

We experimented with Axios, Fetch, and XMLHttpRequest to no avail. Consequently, we decided to devise a native HTTP client that would cater to both platforms and simultaneously ensure simplicity of use.

Currently, the package only supports GET requests. However, we intend to incorporate additional methods as per requirements in the future.

Installation

Install the package using npm:

npm install react-native-http-client --save

Example

To run the example:

yarn

# Android app
yarn example android

# iOS app
yarn example ios

Usage

Basic usage:

import { client } from 'react-native-http-client';

const output = await client.get(
  'https://example.dev/'
);

console.log(output.body);

Usage with headers and parameters:

import { client } from 'react-native-http-client';

const output = await client.get(
  'https://example.dev/',
  {
    headers: {
      'Content-Type': 'application/json',
      'Accept': 'application/json',
    },
    params: {
      'param1': 'value1',
      'param2': 'value2',
    },
  }
);

console.log(output.body);

Contributing

To learn how to contribute to the repository and the development workflow, please refer to the contributing guide.

License

MIT License.


Crafted with care using create-react-native-library.

react-native-http-client's People

Contributors

kevinvdburg avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.