Get to the scripting section by clicking on the script tab inside the request view.
You will see a scripting view with outcommented code. At the bottom right are two buttons, the left for accessing this document, the right for opening the scripting console.
Open the scripting console by clicking on the right button in the bottom right.
Remove the comments of the function by removing the //
at the front and add console.log("Some text");
to the function body. The terminal will now display the message of your script.
The request object which is passedd to the before_sending
function is exactly the same the one which you're
configuring in the request view. You can alter the request here before it is finally sent.
To verify that the request is indeed the same request log the JSON representation of your string to the console.
To get the JSON representation of your request just use the JSON.stringify
function on your request object.
The scripting engine is also able to do HTTP requests. The Build-In section has more information about HTTP
To get started, just make a GET-request to https://jsonplaceholder.typicode.com/photos/5
by using HTTP.get
, store the response in a variable
and log it to the console by using JSON.stringify
.