Methods
# async static delete(url, headers) → {Promise.<Object>}
Perform a DELETE request to the specified URL.
Parameters:
Name | Type | Description |
---|---|---|
url |
string
|
The URL for the DELETE request. |
headers |
Object
|
The headers to include in the request. |
A Promise that resolves with the JSON data from the DELETE request.
Promise.<Object>
Example
const url = 'https://example.com/api/data/123';
const headers = { 'Authorization': 'Bearer YOUR_TOKEN' };
const responseData = await RequestUtils.delete(url, headers);
console.log('DELETE Response:', responseData);
# async static get(url, headers) → {Promise.<Object>}
Perform a GET request to the specified URL.
Parameters:
Name | Type | Description |
---|---|---|
url |
string
|
The URL for the GET request. |
headers |
Object
|
The headers to include in the request. |
A Promise that resolves with the JSON data from the GET request.
Promise.<Object>
Example
const url = 'https://example.com/api/data';
const headers = { 'Authorization': 'Bearer YOUR_TOKEN' };
const responseData = await RequestUtils.get(url, headers);
console.log('GET Response:', responseData);
# async static post(url, headers, body) → {Promise.<(Object|string)>}
Perform a POST request to the specified URL.
Parameters:
Name | Type | Description |
---|---|---|
url |
string
|
The URL for the POST request. |
headers |
Object
|
The headers to include in the request. |
body |
Object
|
The JSON data to include in the request body. |
A Promise that resolves with the JSON data from the POST request.
Promise.<(Object|string)>
Example
const url = 'https://example.com/api/data';
const headers = { 'Content-Type': 'application/json' };
const body = { key: 'value' };
const responseData = await RequestUtils.post(url, headers, body);
console.log('POST Response:', responseData);
# async static put(url, headers, body) → {Promise.<Object>}
Perform a PUT request to the specified URL.
Parameters:
Name | Type | Description |
---|---|---|
url |
string
|
The URL for the PUT request. |
headers |
Object
|
The headers to include in the request. |
body |
Object
|
The JSON data to include in the request body. |
A Promise that resolves with the JSON data from the PUT request.
Promise.<Object>
Example
const url = 'https://example.com/api/data';
const headers = { 'Content-Type': 'application/json' };
const body = { key: 'updatedValue' };
const responseData = await RequestUtils.put(url, headers, body);
console.log('PUT Response:', responseData);