Aqua Help

JavaScript API supported by HTTP Client

console.log

The HTTP Client supports the console.log() method to print the text value (or multiple values separated by commas) to the output of the response handler or pre-request handler scripts. You can also use client.log for the same purpose. Example:

GET example.org > {% console.log(response.status) %}

You can also pass a JavaScript object (for example, console.log(response.body)), and it will be displayed in the output in JSON format with proper syntax highlighting.

URLSearchParams

URLSearchParams is a JavaScript object that makes it easy to work with the query string part of a URL. URLSearchParams accepts parameters in the following formats:

  • Query string: URLSearchParams("key=value&key2=value2");

  • Key-value pairs representing URL parameters: URLSearchParams({ key1: "value1", key2: "value2" })

  • Array of key-value pairs: URLSearchParams([["key1", "value1"], ["key2", "value2"]])

The HTTP Client supports all known URLSearchParams methods. Example:

< {% client.global.set('query', 'foo=1&bar=2') const params = new URLSearchParams(client.global.get('query')); const params2 = new URLSearchParams([["planet", "tatooine"], ["year", "2"]]); const params3 = new URLSearchParams({key1: "value1", key2: "value2"}); console.log(params.has("bar")); // outputs true console.log(params.has("param")); // outputs false params.append("foo", 3); console.log(params.getAll("foo")); // outputs ["1","3"] for (let value of params.values()) { console.log(value); // outputs 1 2 3 } for (let key of params2.keys()) { console.log(key); // outputs planet year } client.global.set("query",params.toString()) %} GET example.org/{{query}}
Last modified: 11 February 2024