wait for a function to complete javacript 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);
}