Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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

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}`;
}
```