react-haiku icon indicating copy to clipboard operation
react-haiku copied to clipboard

Added useFetch hook for simplified Fetch API usage

Open davi1985 opened this issue 1 year ago • 0 comments

This pull request introduces a new custom hook, useFetch, which streamlines the usage of the Fetch API within the project. The useFetch hook is designed to simplify data fetching operations by encapsulating common logic and providing a convenient interface for making HTTP requests.

The useFetch hook accepts two parameters:

path: A string representing the endpoint path or URL to fetch data from.

init (optional): An optional RequestInit object containing additional request configuration options, such as headers or request method.

Inside the useFetch hook, the BASE_URL property is accessed from the environment using process.env.REACT_APP_BASE_URL. This allows for dynamic URL construction based on the base URL defined in the environment variables.

davi1985 avatar Mar 31 '24 18:03 davi1985