useAxios
Wrapper for .
Package: @vueuse/integrations
Category: '@Integrations'
Usage
import { useAxios } from '@vueuse/integrations/useAxios'
const { data, isFinished } = useAxios('/api/posts')Options
| Option | Type | Default | Description |
|---|---|---|---|
| immediate | boolean |
- | Will automatically run axios request when useAxios is used |
| shallow | boolean |
true | Use shallowRef. |
| abortPrevious | boolean |
true | Abort previous request when a new request is made. |
| onError | (e: unknown) => void |
- | Callback when error is caught. |
| onSuccess | (data: T) => void |
- | Callback when success is caught. |
| resetOnExecute | boolean |
- | Sets the state to initialState before executing the promise. |
| onFinish | () => void |
- | Callback when request is finished. |