import {DeleteRequest} from '@serenity-js/rest/lib/model'
public class | source

DeleteRequest

The DELETE method requests that the origin server remove the association between the target resource and its current functionality.

Extends:

Question<Promise<AxiosRequestConfig>>HTTPRequest → DeleteRequest

Examples:

Create and remove a resource
 import { Actor } from '@serenity-js/core';
 import { CallAnApi, DeleteRequest, LastResponse, PostRequest, Send } from '@serenity-js/rest'
 import { Ensure, equals, startsWith } from '@serenity-js/assertions';

 const actor = Actor.named('Apisit').whoCan(CallAnApi.at('https://myapp.com/api'));

 actor.attemptsTo(
     // create a new test user account
     Send.a(PostRequest.to('/users').with({
         login: 'tester',
         password: 'P@ssword1',
     }),
     Ensure.that(LastResponse.status(), equals(201)),
     Ensure.that(LastResponse.header('Location'), startsWith('/users')),

     // delete the test user account
     Send.a(DeleteRequest.to(LastResponse.header('Location'))),
     Ensure.that(LastResponse.status(), equals(200)),
 );

Tests:

Static Method Summary

Static Public Methods
public static

to(resourceUri: Answerable<string>): DeleteRequest

Configures the object with a destination URI.

Method Summary

Public Methods
public

using(config: Answerable<AxiosRequestConfig>): DeleteRequest

Overrides the default Axios request configuration provided when CallAnApi Ability was instantiated.

Inherited Summary

From class HTTPRequest
public

subject: string

public

answeredBy(actor: AnswersQuestions & UsesAbilities): Promise<AxiosRequestConfig>

Resolves the Question in the context of a given Actor

Static Public Methods

public static to(resourceUri: Answerable<string>): DeleteRequest source

Configures the object with a destination URI.

When the resourceUri is not a fully qualified URL but a path, such as /products/2, it gets concatenated with the URL provided to the Axios instance when the CallAnApi Ability was instantiated.

Params:

NameTypeAttributeDescription
resourceUri Answerable<string>

The URI where the Actor should send the HTTPRequest.

Returns:

DeleteRequest

Public Methods

public using(config: Answerable<AxiosRequestConfig>): DeleteRequest source

Overrides the default Axios request configuration provided when CallAnApi Ability was instantiated.

Params:

NameTypeAttributeDescription
config Answerable<AxiosRequestConfig>

Axios request configuration overrides

Returns:

DeleteRequest