I would like to know: how can I get the body data in response to each request in K6?
I tried using console.log(response.body)
, but it did not provide a solution for it. Either it gives a response in binary or displays nothing.
Software Quality Assurance & Testing Stack Exchange is a question and answer site for software quality control experts, automation engineers, and software testers. It only takes a minute to sign up.
Sign up to join this communityIt works for me
const res = http.get(`${url}/v1/`)
check(res, {
'is status 200': (r) => r.status === 200
})
console.log(res.body)
You can just use your the object from your request.
For example
let res = http.post(url, payload,params);
console.log(res.body);
I've found that with some json, nulls have caused issues. In those cases I've used stringify to clean it up before printing.
console.log(JSON.stringify(res, null, " "));