Never Pummel Muskoxen

    @ej-hooks/use-axios

    1.0.0 • Public • Published

    @ej-hooks/use-axios

    React Hook to make HTTPRequest using axios.

    Installation

    yarn

    yarn add @ej-hooks/use-axios

    npm

    npm i @ej-hooks/use-axios

    Usage

    import React from 'react';
    import useAxios from '@ej-hooks/use-axios';
    function App() {
      const { loading, data, refetch } = useAxios({
        url: 'https://yts.mx/api/v2/list_movies.json',
      });
      return (
          <h1>{data && data.status}</h1>
          <h2>{loading && "Loading"}</h2>
          <button onClick={refetch}>Refetch</button>
      );
    }

    Arguments

    Argument Type Description Required
    opts object An object containing the url to send request to yes
    axiosInstance instance An Instance to make request with no

    Return

    Return value Type Description Default value
    state object An object containing the loading, error and data { loading: true, error: null, data: null }
    refetch function Function to execute useEffect again

    Install

    npm i @ej-hooks/use-axios

    DownloadsWeekly Downloads

    1

    Version

    1.0.0

    License

    MIT

    Unpacked Size

    2.91 kB

    Total Files

    4

    Last publish

    Collaborators

    • eunjinfizz