Skip to content

web.delete

Sends a HTTP DELETE request to the specified URL.

js
web.delete(url, headers, base64Body)
web.delete(url, headers, base64Body)

Parameters

  • url (string): The URL to send the DELETE request to.
  • headers (object): An object containing custom headers to include in the request. The keys represent header names, and the values represent the corresponding header values. (optional)
  • base64Body (boolean): A boolean flag indicating whether the response body should be returned as a base64-encoded string. Default value is false. (optional)

Returns

  • response (object): An object representing the HTTP response containing the following properties:
    • status (number): The HTTP status code of the response.
    • headers (array): An array of header objects, where each object has one key/value pair representing a header.
    • body (string): The response body as a string or as a base64-encoded string if the content type is binary.
    • error (string): An error message if an exception occurred while sending the request.

Examples

js
var response = web.delete("https://api.example.com/users/12345", { "Authorization": "Bearer your_token" });

// Check if the response status code is in the success range (between 200 and 299, inclusive).
if (response.status >= 200 && response.status < 300) {
    console.log("Request succeeded.");
    console.log(response.body);
} else if (response.error) {
    // An error occurred while sending the request (e.g., network error, timeout, etc.).
    console.log("Error occurred while sending the request: " + response.error);
} else {
    // The request failed with a non-success status code.
    console.log("Request failed with status code: " + response.status);
    console.log(response.body);
}
var response = web.delete("https://api.example.com/users/12345", { "Authorization": "Bearer your_token" });

// Check if the response status code is in the success range (between 200 and 299, inclusive).
if (response.status >= 200 && response.status < 300) {
    console.log("Request succeeded.");
    console.log(response.body);
} else if (response.error) {
    // An error occurred while sending the request (e.g., network error, timeout, etc.).
    console.log("Error occurred while sending the request: " + response.error);
} else {
    // The request failed with a non-success status code.
    console.log("Request failed with status code: " + response.status);
    console.log(response.body);
}