Hi! I’m new here,
How to use data from one GET request and pass it to another POST request? But this data needs to be updated every time if the post-request was successful.
For example:
export default function() {
const headers = {
'Authorization': `${data.token}`,
'Content-Type': 'application/json'
};
group('Customer', function () {
const getVer = http.get(
'url',
{ headers },)
const versionJson = JSON.parse(getVer.body);
let version = versionJson.result.list[0].version;
console.log("Version:", version);
let body = {
"version": version};
response = http.post(
'url',
JSON.stringify(body),
{ headers },
)
console.log(response);
When I run test, it passes correct version for the first time, but during the next iterations it passes old version value, but it has to be updated every time when post request uses it successfully.