Open robross0606 opened 5 years ago
Try "promisifying" your retrieval and callback logic: https://javascript.info/promisify
Pseudo code:
async function test() {
while(condition) {
try {
await promisify();
} catch {..}
}
}
function promisify() {
return new Promise((resolve, reject) => {
client.get(params, (data, response) => {
// do stuff
resolve();
}).on('err', reject);
}
}
I am absolutely baffled on how to use this client in a do..while loop. It appears the client does an async call, but I cannot seem to get it to await response before continuing.