https://github.com/devxlalit/useapi-hook
A simple customizable react hook for handling API in React JS
https://github.com/devxlalit/useapi-hook
api-rest api-server apigateway hooks-api-react javascript-es6 react react-components react-hooks
Last synced: about 1 month ago
JSON representation
A simple customizable react hook for handling API in React JS
- Host: GitHub
- URL: https://github.com/devxlalit/useapi-hook
- Owner: devXlalit
- Created: 2024-05-15T19:07:35.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-05-15T19:44:33.000Z (about 2 years ago)
- Last Synced: 2025-06-16T02:39:41.797Z (12 months ago)
- Topics: api-rest, api-server, apigateway, hooks-api-react, javascript-es6, react, react-components, react-hooks
- Language: JavaScript
- Homepage:
- Size: 45.9 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# useApi Hook for React Js
A simple customizable react hook for handling API in your react project.
## 🛠 Skills
Javascript , React JS , Node js
## Features
- Handle API Responce
- Handle API Loading
- Handle API error
## Installation
Create vite + React or simple react app
```bash
npx create-react-app project_name
```
Or
```bash
npm create vite@latest
```
### Usage -
## Screenshots

Use this on any component or App.jsx file if you want.
```bash
const [loading, error, response] = useApi(
"http://localhost:3000/api/products/name"
);
if (error) {
return
Something went wrong!
;
}
if (loading) {
return Loading...
;
}
```
Just pass your api on the useApi hook and useApi hook will give your 3 response that are
1. loading - it will check if api is ready or not
2. error - it will throw an error if API dosen't respond
3. response - it will show the result/response of API
we can also handle all the responses and can customize the useApi for our own usecase scenario.
## Authors
- [@lalit-pagare](https://github.com/lalit-pagare)
- [@devXlalit](https://github.com/devXlalit)
## Support
For support, Just Star ⭐ the Repo and enjoy learnig the most usefull customizable react hook😎😎