The parameters for the API call. This includes:
method: The name of the API method or endpoint to call.httpMethod: The HTTP method to use for the request (e.g., 'GET', 'POST').params (optional): The query parameters to include in the request. Used if httpMethod is 'GET'.data (optional): The body data to include in the request. Used if httpMethod is not 'GET' (e.g., 'POST', 'PUT').A promise that resolves to the response message from the API call. The response typically includes the result of the method call or relevant data based on the API endpoint.
// Make a GET request to fetch user data.
const response = await callMethod({
method: 'user.get',
httpMethod: 'GET',
params: { userId: '123' },
});
console.log(response); // Logs the response data for the user with ID 123
Makes a general API call to a specified method with optional parameters and data.
This function performs an asynchronous request to the server using a specified HTTP method. The method and endpoint are defined by the
methodparameter, and the HTTP method (GET, POST, etc.) is specified by thehttpMethodparameter. Depending on the HTTP method, eitherparamsordatais included in the request.