/use-axios-client

Make axios requests in React using hooks.

Primary LanguageTypeScriptMIT LicenseMIT


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