I want to run a code sequentially in the order it is written but using console I am seeing that the code below is being run midway (while the timer is still running). I want it to run after the timer closes (preferably 1 second later timer reaches 0). I have tried async and await but not getting the required results.
export function button1_click(event) {
number = number + 1;
$w('#list').setCurrentItemIndex(number);
$w("#names").setFieldValues( {
"status": "Running",
"number": number
} );
let seconds = 12;
let countdown = setInterval(function () {
if (seconds >= 0) {
$w('#admintimertext').text = seconds + " seconds left"
seconds = seconds - 1
} else {
clearInterval(countdown)
}
},1000);
$w("#names").setFieldValues( {
"status": "Pause"
}
)
}
Please help. Not able to figure out where I went wrong.