Add some features from useFetch also to useAxios
See original GitHub issueCurrently useFetch has execute(), but useAxios does not. This means that with useFetch you can first create useFetch, set {immediate: false}, then execute() the call later, but with useAxios it fires immediately when you call useAxios.
Abort is also missing in useAxios.
Some properties don’t make sense to add into axios such as statusText (since that’s just in the axios response).
Another thing is that the returned property names are different in useAxios and useFetch, but changing that’d be a breaking change.
Exposed logic from both logics:
useAxios
response: Ref<AxiosResponse<T> | undefined>
data: Ref<T | undefined>
finished: Ref<boolean>
loading: Ref<boolean>
canceled: Ref<boolean>
error: Ref<AxiosError<T> | undefined>
useFetch
isFinished: Ref<boolean>
statusCode: Ref<number | null>
response: Ref<Response | null>
error: Ref<any>
data: Ref<T | null>
isFetching: Ref<boolean>
canAbort: ComputedRef<boolean>
aborted: Ref<boolean>
abort: Fn
execute: () => Promise<any>
Issue Analytics
- State:
- Created 2 years ago
- Reactions:2
- Comments:8 (5 by maintainers)
Top Results From Across the Web
Axios vs. fetch(): Which is best for making HTTP requests?
The fetch() API is perfectly capable of reproducing the key features of Axios, and it has the added advantage of being readily available...
Read more >useAxios : A simple custom hook for calling APIs using axios
Add withAxios HOC to wrap and inject these properties into any "dumb" component. Provide an example extending the hook to tailored hooks: const ......
Read more >useFetch - VueUse
The following URLs can be used to test different features of useFetch ... You can read more about the suspense api in the...
Read more >How to Fetch Data in React With A Custom useFetch Hook
In this video I will show how to make a custom useFetch hook in react. The hook allows you to fetch data from...
Read more >useFetch — A Custom React Hook - Medium
Without using a custom hook, you would probably do something similar to this: ... Let's start to add the features I mentioned above....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Would love to align those interfaces. We can make aliases and for APIs and mark some as deprecated. Then drop them in along with the next major.
Aligning with useFetch looks better to me