# vue-axios-hooks

> [![npm version](https://badge.fury.io/js/vue-axios-hooks.svg)](https://badge.fury.io/js/vue-axios-hooks)

Latest version **0.1.6** (published 2020-07-31) · MIT license · 0 weekly downloads

## Install

```sh
npm install vue-axios-hooks
pnpm add vue-axios-hooks
yarn add vue-axios-hooks
bun add vue-axios-hooks
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.6 |
| Published | 2020-07-31 |
| First published | 2020-07-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 6 |
| Unpacked size | 12.2 KB |
| Known vulnerabilities | 0 (+25 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 11 |
| Author | Yan |
| Maintainers | elon-yan |
| Keywords | vue, axios, hooks |

## Links

- npm: https://www.npmjs.com/package/vue-axios-hooks
- Repository: https://github.com/Elon-Yan/vue-axios-hooks
- Homepage: https://github.com/Elon-Yan/vue-axios-hooks#readme
- Issues: https://github.com/Elon-Yan/vue-axios-hooks/issues
- npm.io page: https://npm.io/package/vue-axios-hooks

## Dependencies (6)

- [vue](https://npm.io/package/vue.md) ^3.0.0-beta.1
- [axios](https://npm.io/package/axios.md) ^0.19.2
- [lodash](https://npm.io/package/lodash.md) ^4.17.19
- [rollup](https://npm.io/package/rollup.md) ^2.21.0
- [core-js](https://npm.io/package/core-js.md) ^3.6.5
- [rollup-plugin-vue](https://npm.io/package/rollup-plugin-vue.md) ^6.0.0-beta.6

## Recent versions

- 0.1.6 (latest) — 2020-07-31
- 0.1.5 — 2020-07-22
- 0.1.4 — 2020-07-21
- 0.1.3 — 2020-07-21
- 0.1.2 — 2020-07-19
- 0.1.1 — 2020-07-14
- 0.1.0 — 2020-07-13

## README

# vue-axios-hooks
[![npm version](https://badge.fury.io/js/vue-axios-hooks.svg)](https://badge.fury.io/js/vue-axios-hooks)

Vue3 hooks for [axios]

## Installation

`npm install axios vue-axios-hooks`

## Quick Start

```js
<script>
import useAxios from 'vue-axios-hooks'

export default {
  setup () {
    const { refetch, loading, data, cancel, error } = useAxios({
      url: 'https://reqres.in/api/users?delay=1'
    })

    refetch()

    return {
      loading,
      refetch,
      data,
      cancel,
      error
    }
  }
}
</script>
```

## Configuration

```js
<!-- App.vue -->
<script>
import Axios from 'axios'
import { useConfigure } from 'vue-axios-hooks'

export default {
  setup () {
    const axios = Axios.create({
      baseURL: 'https://reqres.in/api'
    })

    axios.interceptors.response.use(
      (res) => {
        return res.data
      }
    )
    useConfigure({ axios })
  }
}
</script>
```

## Debounce
If `options.debounce` is set, requests except for the last one within the debounce interval will be dropped.
```js
const { refetch, loading, data } = useAxios({
  url: 'https://reqres.in/api/users?delay=1'
}, {
  debounce: 300
})
```

## Throttle
If `options.throttle` is set, the request will be triggered once maximum within the throttle interval.
```js
const { refetch, loading, data } = useAxios({
  url: 'https://reqres.in/api/users?delay=1'
}, {
  throttle: 1000
})
```
> `debounce` and `throttle` can only be set to one

## License

MIT

[axios]: https://github.com/axios/axios

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