fetcher-safe
v0.1.2
Published
`fetcher-safe` is a React custom hook designed to simplify the management of asynchronous data fetching in your React applications. It provides a convenient way to handle loading states, errors, and successful data retrieval.
Downloads
1
Maintainers
Readme
fetcher-safe
A custom React hook for handling data fetching with status management.
Installation
You can install this package via npm using the following command:
npm install fetcher-safe
## Usage
Here's how you can use the useFetcher hook in your React component:
import { useFetcher } from 'fetcher-safe';
function MyComponent() {
const { fetchStatus, data, getUser } = useFetcher();
// Use the getUser function and access fetchStatus and data as needed
return (
<div>
{/* Your component using fetchStatus and data */}
</div>
);
}
## Features
Efficiently handles data fetching with status tracking.
Supports cancellation of fetch requests.
## API
# useFetcher
The useFetcher hook returns an object with the following properties and methods:
fetchStatus: The current status of the data fetching process.
data: The fetched data.
getUser(ENDPOINT: string, API_URL: string): A function to initiate the data fetching process.
## Configuration
No specific configuration is required. However, ensure you have React and its dependencies installed in your project.
© coreasofts