angelle-sw / use-axios-client

Make axios requests in React using hooks.

Home Page:https://use-axios-client.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool


use-axios-client

Make axios requests in React using hooks.

CircleCI codecov License: MIT

Installation

with npm:

$ npm install use-axios-client

with yarn:

$ yarn add use-axios-client

Example

import { useAxios } from 'use-axios-client';

export default () => {
  const { data, error, loading } = useAxios({
    url: 'https://example/api',
  });

  return (
    <>
      {loading && <div>Loading...</div>}
      {error && <div>{error.message}</div>}
      {data && <div>{data}</div>}
    </>
  );
};

Docs

Contributing

Clone the repository:

$ git clone https://github.com/angelle-sw/use-axios-client

Install dependencies:

$ yarn

Run the example app at http://localhost:8080:

$ cd example
$ yarn
$ yarn start

Run tests using jest:

$ yarn test

About

Make axios requests in React using hooks.

https://use-axios-client.io

License:MIT License


Languages

Language:TypeScript 97.5%Language:JavaScript 2.5%