WebStorm 2023.1 Help

HTTP Client reference

The client object holds the HTTP Client session metadata, such as the list of global variables. The HTTP Client session is started when WebStorm starts, and ends when WebStorm is closed. Values are not preserved between WebStorm restarts.

The client provides access to the global nested object that serves as a variable storage.

Properties

Property

Description

global

The global variables storage, which is used for setting, retrieving, or removing variables.

Once you assign a value to a global variable (client.global.set(VariableName, VariableValue)), you can access it as {{VariableName}} in subsequent HTTP requests or using client.global.get("VariableName") in response handler scripts and pre-request scripts. See Use global variables for a more detailed example.

Methods

Method

Parameters

Description

test

testName (string)

func (function)

Creates a test with the name testName and body func. All tests are executed after the response handler script. Test results are displayed in the Tests tab of the Services tool window.

assert

condition (boolean)

message (string)

Checks that the specified condition is true; throws an exception otherwise. The optional message parameter serves as an exception message.

log

text

Prints text to the response handler or test stdout and then terminates the line.

exit

Terminates execution of the response handler script.

Global variables storage

The global object serves as a variable storage and is used for setting, retrieving, or removing variables. These variables are global because, once set, they can be accessed from any HTTP request.

Methods

Method

Parameters

Description

set

varName (string)

varValue (string)

Saves the variable with the varName name to the storage and sets its value to varValue. See Use global variables for a more detailed example.

get

varName (string)

Returns the value of the varName variable.

isEmpty

Checks whether the global object has no variables defined.

clear

varName (string)

Removes the varName variable from the variables storage.

clearAll

Removes all variables from the variables storage.

Last modified: 21 April 2023