Hi @jabastinp
You could try a poll function that verifies if your previous request has the results you want it to have.
Hope this helps!
let addAssetToQueue = http.post(`${__ENV.URL}/assets/queuedownload`, JSON.stringify(body), params);
let start = Date.now();
downloadKey = addAssetToQueue.json()['downloadKey']
console.log('Download key: ' + downloadKey)
function pollForPresignedUrl () {
params = {
headers : header,
tags: {name: "poll for presigned url"},
}
let downloadFromQueue = http.get(`${__ENV.URL}/downloadfromqueue/${downloadKey}`, params)
var status = downloadFromQueue.json()['status'] === 'done'
if (status) {
console.log('START '+ "VU USER " +__VU + 'Iteration ' + __ITER + 'Date time ' + utcStr)
console.log('DONE with polling, url stored.')
presigned = downloadFromQueue.json()['assets'][0]['presigned_url']
serverWaitingTimeToDownloadQueuedAsset.add(Date.now() - start);
return this
} else {
console.log('START '+ " VU USER " +__VU + ' Iteration ' + __ITER + ' Date time ' + utcStr)
console.log('Still polling for presigned URL... ')
sleep(0.2);
pollForPresignedUrl();
}
}
pollForPresignedUrl();