Hi,
Thanks for the awesome tools.
Currently I am setting the options of k6 to discard response bodies
export const options = {
discardResponseBodies: true
}
This will discard all the bodies of the http response in setup and vu step I assumed.
So how could I fetch the JSON response in setup step to use in vu step meanwhile still discard the response bodies in vu step?
I already tried with setting Params.responseType
to text
but it seems the discardResponseBodies
will overwrite set the body to null
with this option.
Thanks in advance,
1 Like
This is the way to negate discardResponseBodies
and get the response body of individual requests. Can you share a code snippet that demonstrates the issue, since I can’t reproduce it. This code works like how you’d expect it to work:
import http from 'k6/http'
export let options = {
discardResponseBodies: true,
}
export function setup() {
let res1 = http.get('https://test.k6.io/');
console.log(res1.body); // prints null
let res2 = http.get('https://test.k6.io/pi.php?decimals=3', { responseType: "text" });
console.log(res2.body); // prints the body
}
export default function () {
}
2 Likes
Thanks for taking a look into the issue.
I retried the same code structure and the feature worked flawlessly. What I did was power off the computer and went home
Probably I made a mistake when using responseType
. Silly me!
If any issue arises in this category, I will let you know.
Thank you for taking your time. Please consider this issue resolved.
2 Likes