-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
Description
Overview
This article presents the use cases of an HTTP client and provides a solution for customizing a http client util utilizing window.fetch.
Requirements Analysis
- In certain scenarios, a single page application might utilize multiple API service resources, necessitating the customization of each request group with its distinct API base URL.
- Learning from the popular http client solution, axios.js, a http client needs to offer http request methods directly (such as DELETE, GET, PATCH, PUT, or POST). It would be highly beneficial if the HTTP client utility could directly expose these methods for ease of use. For example
httpClientInstance.get
httpClientInstance.post
HttpClient.get
HttpClient.post- Support for retrying a failed request, ensuring that the system can automatically attempt the request again in case of failure
- Support aborting a request when necessary, for example, when a component is unmounted then corresponding request needs to be cancelled.