wait for async function to finish javascript code example
Example: how to wait for a function to finish in javascript
function doFirst() {
return new Promise(function(resolve, reject) {
//do a thing
if (){
return reject(value);
}
resolve(value);
});
});
}
async function doSecond() {
var outputValue = await doFirst();
console.log(outputValue);
}