0.0.2 • Published 3 years ago

react-axios-query v0.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

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