Protected ReadonlybaseThe base URL for all API requests. Must be defined in subclasses.
ProtectedoptionsProtectedafterThis method is called after the response is received. It can be used to process or inspect the response before returning it.
The response object that was received.
A promise that resolves to the (possibly processed) response.
ProtectedbeforeThis method is called before the request is sent. It can be used to modify the request before it is sent (e.g., adding headers).
The request object that will be sent.
A promise that resolves to the (possibly modified) request.
Sends a fetch request to the specified path, using the provided
RequestInit options.
The path to send the request to, relative to baseURL.
Optionalinit: RequestInitOptional request options.
A promise that resolves to the response from the request.
The
APIClientclass provides a basic HTTP client for making API requests. It includes methods for makingGET,POST,PUT,PATCH, andDELETErequests.Subclasses should define the
baseURLto specify the root URL for all requests.The class allows for customization of the request and response through the
beforeandafterhooks, which can be overridden in subclasses to modify behavior before sending a request or after receiving a response.Example