# @sjblurton/use-axios-get

> useAxiosGet gets data form a rest API, stores it in the cache, error handles, and passes a status for loading, error, and successful fetching.

Latest version **0.1.4** (published 2022-04-16) · MIT license · 0 weekly downloads

## Install

```sh
npm install @sjblurton/use-axios-get
pnpm add @sjblurton/use-axios-get
yarn add @sjblurton/use-axios-get
bun add @sjblurton/use-axios-get
```

## Health

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

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.4 |
| Published | 2022-04-16 |
| First published | 2022-04-15 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=10 |
| Dependencies | 2 |
| Unpacked size | 14.7 KB |
| Known vulnerabilities | 0 (+23 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Simon Blurton |
| Maintainers | sjblurton |
| Keywords | react, hooks, custom, typescript, test, testing, mock server testing |

## Links

- npm: https://www.npmjs.com/package/@sjblurton/use-axios-get
- Repository: https://github.com/sjblurton/use-axios-get
- npm.io page: https://npm.io/package/@sjblurton/use-axios-get

## Dependencies (2)

- [swr](https://npm.io/package/swr.md) ^1.3.0
- [axios](https://npm.io/package/axios.md) ^0.26.1

## Alternatives

- [duck](https://npm.io/package/duck.md) — 4.2M weekly downloads
- [ava](https://npm.io/package/ava.md) — 560.2K weekly downloads
- [storybook-addon-module-mock](https://npm.io/package/storybook-addon-module-mock.md) — 71.7K weekly downloads
- [@ethereum-waffle/mock-contract](https://npm.io/package/@ethereum-waffle/mock-contract.md) — 40.0K weekly downloads
- [aws-elasticsearch-connector](https://npm.io/package/aws-elasticsearch-connector.md) — 37.4K weekly downloads

## Recent versions

- 0.1.4 (latest) — 2022-04-16
- 0.1.3 — 2022-04-16
- 0.1.2 — 2022-04-15
- 0.1.1 — 2022-04-15
- 0.1.0 — 2022-04-15

## README

# useAxiosGet

useAxiosGet gets data form a rest API, stores it in the cache, error handles, and passes a status for loading, error, and successful fetching.

### **install**

```bash
npm i @sjblurton/use-axios-get

yarn add @sjblurton/use-axios-get
```

### Import useArray

```bash
import useAxiosGet from "@sjblurton/use-axios-get";
```

### **To call the hook...**

```bash
  const {status, data, error, mutate} = useAxiosGet<Data>(

```

### **Possible Use Sanarios**

```bash
function App() {
  const {status, data: todos, error, mutate} = useAxiosGet<MockData>(
    "https://jsonplaceholder.typicode.com/todos"
  );

  if (status === "idle") return <div>idling...</div>;
  if (status === "pending") return <div>loading...</div>;
  if (status === "error") return <div>{error?.message}</div>;

  return (
    <div className="App">
      {todos?.map((todo) => (
        <h2>{todo.title}</h2>
      ))}
      <button onClick={mutate}>Mutate</button>
    </div>
  );
}
```

### **Links**

GitHub: https://github.com/sjblurton/use-axios-get
<br/>
NPM: https://www.npmjs.com/package/@sjblurton/use-axios-get

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