Skip to content

πŸ”— A lightweight custom React hook for making HTTP requests using Axios β€” supports GET, POST, PUT, PATCH, DELETE and more. Features auto/manual fetching, refetching, and optional custom Axios instance.

License

Notifications You must be signed in to change notification settings

devmdrd/axios-react-hook

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

5 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

axios-react-hook

A simple and customizable React hook for making HTTP requests using Axios.

Features

  • βœ… Supports GET, POST, PUT, DELETE, PATCH, etc.
  • βœ… Auto and manual fetching
  • βœ… Refetch support
  • βœ… Pass your own Axios instance

Installation

npm install axios-react-hook

Usage

import useAxios from 'axios-react-hook';
import axiosInstance from './axiosInstance'; // Optional custom instance

const { data, loading, error, refetch } = useAxios(
  'https://jsonplaceholder.typicode.com/posts',
  'get',
  null,
  true,
  axiosInstance
);

API

Parameters

Param Type Default Description
url string β€” Request URL
method string 'get' HTTP method
data object null Request payload or query params
auto boolean true Auto execute request on mount
instance AxiosInstance axios Custom Axios instance (optional)

License

MIT

About

πŸ”— A lightweight custom React hook for making HTTP requests using Axios β€” supports GET, POST, PUT, PATCH, DELETE and more. Features auto/manual fetching, refetching, and optional custom Axios instance.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published