Hi,
I still have some issue’s with async/await. i looked around alot and i thought i understood, but seems like something goes wrong. here is a piece of code that i am testing with.
export async function button14_click(event) {
console.log("Before the repeater starts",1)
let sizeDatabase
await $w("#repeater1").forEachItem(async ($w,itemData,index)=>{
console.log("in the repeater",2)
await setTimeout(async function(){
await console.log("in timeout function", 3)
const breedte = await changeSizeToDatabaseSearchValue($w("#txtBreedte").value, $w("#ddBreedteAfSpan").value)
const hoogte = await changeSizeToDatabaseSearchValue($w("#txtHoogte").value , $w("#ddHoogteDagAf").value)
sizeDatabase = await checkSize(breedte, hoogte)
}, 1000);
await console.log(sizeDatabase,4)
})
await console.log("na repeater",5)
}
//result
//1
//2
//5
//4
//3
i used the setTimeout to replace a query to the database, just to test. what i want is to do evrything in the right order.
I use changeSizeToDatabaseSearchValue to change the value of txtBreedte and txtHoogte, depending on a dropdown value and store it in breedte and hoogte. then i want to check if the changed values are good by using checkSize and i store them in sizeDatabase as a object {“breedte”: breedte, “hoogte” : hoogte")
after that i want to do something with those values stored in sizeDatabase, but whatever i do i keep getting undefined.
Any idea what i do wrong? kind regards
Kristof.