API Interaction Utility for Satoshi Showdown. This module facilitates communication with external APIs by abstracting the complexity of making HTTP requests and handling responses and errors. It supports various types of API requests including GET and POST.
- Source:
Requires
- module:axios
- module:utils/logUtil
Methods
(async, inner) deleteAPI(url) → {Promise.<Object>}
Performs a DELETE request to the specified URL and returns the response data. Logs an error message and throws an error if the request fails.
Parameters:
Name | Type | Description |
---|---|---|
url |
string | The URL to send the DELETE request to. |
- Source:
Throws:
-
If the DELETE request fails.
- Type
- Error
Returns:
A promise that resolves with the data from the response.
- Type
- Promise.<Object>
(async, inner) getAPI(url, paramsopt) → {Promise.<Object>}
Performs a GET request to the specified URL and returns the response data. Logs an error message and throws an error if the request fails.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
url |
string | The URL to send the GET request to. |
||
params |
Object |
<optional> |
{} | Optional query parameters for the GET request. |
- Source:
Throws:
-
If the GET request fails.
- Type
- Error
Returns:
A promise that resolves with the data from the response.
- Type
- Promise.<Object>
(async, inner) postAPI(url, data) → {Promise.<Object>}
Performs a POST request to the specified URL with the provided data and returns the response data. Logs an error message and throws an error if the request fails.
Parameters:
Name | Type | Description |
---|---|---|
url |
string | The URL to send the POST request to. |
data |
Object | The payload for the POST request. |
- Source:
Throws:
-
If the POST request fails.
- Type
- Error
Returns:
A promise that resolves with the data from the response.
- Type
- Promise.<Object>
(inner) processCallback(callbackData)
Placeholder function for processing callback data from an external API. This function should be implemented to handle specific callback logic.
Parameters:
Name | Type | Description |
---|---|---|
callbackData |
Object | The data received from the callback. |
- Source: