Deleting Resources (DELETE)
How to delete JSON:API resources using DrupalClient.
⚠️
The deleteResource
helper is available in next-drupal ^1.4.0
.
The DrupalClient
ships with a deleteResource
method for deleting JSON:API resources.
deleteResource
Delete an article by id.
const deleted = await drupal.deleteResource( "node--article", "a937dd34-5407-4fff-8594-fccaaa5bb72a" // <-- Article ID)
See the API reference for deleteResource.
Authentication
To make authenticated requests when deleting resources, use the withAuth
option.
See the authentication docs for the supported authentication methods.
const deleted = await drupal.deleteResource( "node--article", "a937dd34-5407-4fff-8594-fccaaa5bb72a", { withAuth: // <-- Your auth method here. })