# @ib-hooks/use-axios

> React Hook to fetch or re-fetch api using axios easier.

Latest version **1.0.1** (published 2021-08-27) · MIT license · 0 weekly downloads

## Install

```sh
npm install @ib-hooks/use-axios
pnpm add @ib-hooks/use-axios
yarn add @ib-hooks/use-axios
bun add @ib-hooks/use-axios
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2021-08-27 |
| First published | 2021-08-27 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 3.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Inwook Baek |
| Maintainers | inwookie |
| Keywords | React, Hooks, Axios |

## Links

- npm: https://www.npmjs.com/package/@ib-hooks/use-axios
- Repository: https://github.com/inwookie/custom-react-hooks
- Homepage: https://github.com/inwookie/custom-react-hooks#readme
- Issues: https://github.com/inwookie/custom-react-hooks/issues
- npm.io page: https://npm.io/package/@ib-hooks/use-axios

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 1.0.1 (latest) — 2021-08-27
- 1.0.0 — 2021-08-27

## README

# @ib-hooks/use-axios

React Hook to **fetch or re-fetch api using axios easier.**

## Installation

#### yarn

`yarn add @ib-hooks/use-axios`

#### npm

`npm i @ib-hooks/use-axios`

## Usage

```js
import React from "react";
import useAxios from "@ib-hooks/use-axios";

function App() {
  const {
    response: { loading, data, error },
    refetch,
  } = useAxios({ url: API_URL });

  return (
    <div>
      <h1>{data && data.status}</h1>
      <h2>{error && error.message}</h2>
      <h3>{loading && "fetching..."}</h3>
      <button onClick={refetch}>Refetch API</button>
    </div>
  );
}
```

### Arguments

| **Argument**  | **Type** | **Description**                                            | **Required** | **Default value** |
| ------------- | -------- | ---------------------------------------------------------- | ------------ | ----------------- |
| options       | object   | [Reference](https://github.com/axios/axios#request-config) | yes          | undefined         |
| axiosInstance | object   | You can choose axios instance customly.                    | no           | defaultAxios      |

### Return

| **Return value**                     | **Type** | **Description**                                                  |
| ------------------------------------ | -------- | ---------------------------------------------------------------- |
| object(`response`, `refetch`)        | object   | See below                                                        |
| response(`loading`, `data`, `error`) | object   | Response data of fetch api.                                      |
| refetch                              | function | The refetch function executes when the user want to refetch api. |

---
_Source: https://npm.io/package/@ib-hooks/use-axios · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
