delete()
Function Signature
delete: <T>(api?: string) => DenchGetBuilder<T>
Related RequestInit Property
{
method: 'DELETE'
}
Description
Returns a DenchGetBuilder<T> for configuring a DELETE request. An empty API path is used when api is omitted.
If the server returns a JSON response, specify the generic type T and receive it with toJson(). Use toResponse() when you do not need a response body.
Example
import { dench } from 'dench-fetch';
const api = dench('https://api.example.com');
await api
.delete('/users/1')
.toResponse();
The executed request is equivalent to:
fetch('https://api.example.com/users/1', {
method: 'DELETE',
});
Notes
delete()returns aDenchGetBuilder<T>, so it does not provide methods for sending a request body.- Calling
delete()does not execute the request.