# @react-daily-hooks/use-axios

> React Hook to fetch using axios.

Latest version **1.0.2** (published 2019-07-04) · MIT license · 0 weekly downloads

## Install

```sh
npm install @react-daily-hooks/use-axios
pnpm add @react-daily-hooks/use-axios
yarn add @react-daily-hooks/use-axios
bun add @react-daily-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.2 |
| Published | 2019-07-04 |
| First published | 2019-07-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 3.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Taesu Hyeon |
| Maintainers | qvil |
| Keywords | react, react-hooks, hooks, hook, axios |

## Links

- npm: https://www.npmjs.com/package/@react-daily-hooks/use-axios
- Repository: https://github.com/qvil/react-daily-hooks
- Homepage: https://github.com/qvil/react-daily-hooks#readme
- Issues: https://github.com/qvil/react-daily-hooks/issues
- npm.io page: https://npm.io/package/@react-daily-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.2 (latest) — 2019-07-04
- 1.0.1 — 2019-07-04
- 1.0.0 — 2019-07-03

## README

# useAxios

React Hook to fetch using axios.

## Install

```
npm i @react-daily-hooks/use-axios
```

## Basic Usage

[Live Demo(Code Sandbox)](https://codesandbox.io/s/react-daily-hooksuse-axios-example-kur53)

```js
import React, { useState } from "react";
import useAxios from "@react-daily-hooks/use-axios";

const App = () => {
  const [fetchTrigger, setFetchTrigger] = useState(false);
  const { loading, error, data } = useAxios(
    {
      url: "http://ddragon.leagueoflegends.com/api/versions.json"
    },
    fetchTrigger
  );

  const refetch = () => {
    setFetchTrigger(true);
  };

  return (
    <div>
      <h1>UseAxios</h1>
      <h2>{loading && "Loading..."}</h2>
      <h2>{error && `error : ${error}`}</h2>
      <h2>{!loading && !error && data && `status : ${data.status}`}</h2>
      <button onClick={refetch}>refetch</button>
    </div>
  );
};
```

## Parameters

| Parameter | Type    | Description                                                              | Required | Default Value |
| --------- | ------- | ------------------------------------------------------------------------ | -------- | ------------- |
| url       | string  | API URL                                                                  | yes      | undefined     |
| autoFetch | boolean | Fetch trigger, If you want to not fetch automatically set value to false | no       | true          |

## Return value

| value   | Type    | Description     |
| ------- | ------- | --------------- |
| loading | boolean | Loading state   |
| error   | boolean | Error           |
| data    | boolean | Data from axios |

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