1.1.0 • Published 1 year ago

@r-hooks/use-axios v1.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

@r-hooks/use-axios

npm version

react hook for using axios.

Installation

npm

npm install @r-hooks/use-axios

Usage

useAxios(options[, axiosinstance])

import useAxios from "@r-hooks/use-axios";

function App() {
    const options = {
        url:"/api/get/1"
    }
    const { loading, data, error, refetch } = useAxios(options);
    const hanlerWithAnotherOption = ()=>{
        const option = {
            url:"/api/get/2"
        }
        refetch(option);
    }
    return (
        <div>
            <h1>UseAxios</h1>
            <h2>{data?.status}</h2>
            <h3>{loading && "Loading..."}</h3>
            <button onClick={refetch}>refetch with same option</button>
            <button onClick={hanlerWithAnotherOption}>refetch with another option</button>
        </div>
    );
}
1.1.0

1 year ago

1.0.8

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago