The res object that is available inside the vars, assertions, scripting and testing contexts can be used to extract values from the response body, headers and status.
Note that the res object is only available in the context of a request.
You can also access it with response queries.
The res object has the following properties:
The body property of the res object contains the response data sent to the client. It can be a string, an object, or a stream, depending on the application's needs.
The headers property contains HTTP headers associated with the response. These headers provide metadata about the response, such as content type, encoding, and caching directives.
The status property represents the HTTP status code of the response. It indicates the outcome of the request, such as success, redirection, client error, or server error.
// Example response object const res = body: '', headers: 'Content-Type': 'application/json', 'Cache-Control': 'no-cache', >, status: 200, >; // Accessing response properties console.log(res.body); // Output: '' console.log(res.headers['Content-Type']); // Output: 'application/json' console.log(res.status); // Output: 200