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

OptionsRequest

The OPTIONS method requests information about the communication options available for the target resource, at either the origin server or an intervening intermediary. This method allows a client to determine the options and/or requirements associated with a resource, or the capabilities of a server, without implying a resource action.

Extends:

Question<Promise<AxiosRequestConfig>>HTTPRequest → OptionsRequest

Examples:

File download test
 import { Actor } from '@serenity-js/core';
 import { CallAnApi, OptionsRequest, LastResponse, Send } from '@serenity-js/rest'
 import { Ensure, equals } from '@serenity-js/assertions';

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

 actor.attemptsTo(
     Send.a(OptionsRequest.to('/downloads/my-test-document.pdf')),
     Ensure.that(LastResponse.status(), equals(200)),
     Ensure.that(LastResponse.header('Allow'), equals('OPTIONS, GET, HEAD')),
 );

Static Method Summary

Static Public Methods
public static

to(resourceUri: Answerable<string>): OptionsRequest

Configures the object with a destination URI.

Method Summary

Public Methods
public

using(config: Answerable<AxiosRequestConfig>): OptionsRequest

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>): OptionsRequest 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:

OptionsRequest

Public Methods

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

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

Params:

NameTypeAttributeDescription
config Answerable<AxiosRequestConfig>

Axios request configuration overrides

Returns:

OptionsRequest