react-axios-query
TypeScript icon, indicating that this package has built-in type declarations

0.0.2 • Public • Published

react-axios-query

Combine the power of react-query and axios.

install

yarn add react-axios-query

use

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<User>({
      method: 'GET',
      url: '/user/1'
    });
  if(isLoading) {
    return 'Loading...';
  }
  if(error) {
    return `Error: ${$error}`;
  }
  return `Status: ${status}, User: ${user}`;
}

Readme

Keywords

none

Package Sidebar

Install

npm i react-axios-query

Weekly Downloads

1

Version

0.0.2

License

MIT

Unpacked Size

93.1 kB

Total Files

12

Last publish

Collaborators

  • ecyrbe