Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ecyrbe/react-axios-query
combine the power of react-query and axios
https://github.com/ecyrbe/react-axios-query
Last synced: 21 days ago
JSON representation
combine the power of react-query and axios
- Host: GitHub
- URL: https://github.com/ecyrbe/react-axios-query
- Owner: ecyrbe
- License: mit
- Created: 2021-05-20T19:47:01.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-12-15T11:52:06.000Z (11 months ago)
- Last Synced: 2024-10-10T16:47:44.971Z (about 1 month ago)
- Language: TypeScript
- Size: 97.7 KB
- Stars: 13
- Watchers: 3
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# react-axios-query
Combine the power of react-query and axios.
## install
```bash
yarn add react-axios-query
```# use
```javascript
import { useAxios } from 'react-axios-query';type User = {
name: string;
phone: string;
website: string;
}const Component = (props) => {
const {
isLoading,
data: {
data: user
status
},
error,
isFetching
} = useAxios({
method: 'GET',
url: '/user/1'
});
if(isLoading) {
return 'Loading...';
}
if(error) {
return `Error: ${$error}`;
}
return `Status: ${status}, User: ${user}`;
}
```