Is it a bad practice to use a await inside a while loop?
I have the following code:
// this is inside a async function
try {
let res = await api.resource.create(...args) // create resource
do {
let res = await api.resource.show(res.body.id)
if (res.body.status === 'COMPLETED')
return res.body
} while(1)
} catch (err) {
errorHandler(err)
}
I have a couple of questions here:
- Is it ok to use two res variables?
- Am I going to use performance because I'm using a await inside a while loop?
- Is there a better solutin?
Thank you in advance.