Appearance
Data Fetching
Building a reusable API client can greatly simplify your development process, making it more manageable and reducing the risk of errors.
We provide tailored solutions for data collection based on your specific needs. Generally, we establish the data retrieval process by configuring settings like setting a base URL for all API requests, adjusting headers, and implementing interceptors for authentication
Custom Instance
The Reactive Fetch API enables you to abort and intercept requests before they are sent, automatically prefetching data when the URL changes. It also allows you to create a customized useFetch hook with predefined options for even greater flexibility
File :
src/plugins/useFetch.js
In this file, we've included the onFetchError and beforeFetch functions to assist with authentication and handle data and error responses.
The beforeFetch option allows you to intercept a request before it’s sent, enabling modifications to the request options and URL.
The onFetchError option intercepts the response data and error, allowing for customized error handling.
WARNING
Modify this section if the response structure of your API is different.
To learn more about useFetch , please read its official documentation here.