Creates an instance of RestApi
.
The base URL of the API server (e.g., "https://api.example.com").
The authorization token to include in the request headers.
Static
HttpEnum-like object defining supported HTTP methods. This is a constant object that maps HTTP method names to their string representations.
Available methods:
GET
: Fetch data from the server.POST
: Submit data to the server.PUT
: Replace data on the server.PATCH
: Partially update data on the server.DELETE
: Remove data from the server.Sends an HTTP request to the server using the specified method and URL.
The HTTP method to use (GET, POST, PUT, PATCH, DELETE).
The endpoint URL (relative to the base URL).
Optional
body: anyOptional data to send in the request body (used with POST, PUT, PATCH).
A promise that resolves to the server's response data.
The
RestApi
class provides a simplified interface for making HTTP requests to a specified server using Axios. It supports common HTTP methods and manages authorization headers.