Hello wix community.
i’m with a strugle here.
is it possible to access an item like this , result.items[0].“String”
here is my code.
async function getPercent (product,prijs) {
return await wixData.query("Kortingen")
.eq("klant",selectedEmail)
.find()
.then((result)=>{
console.log("before r")
let r = result.items[0].product // product links to the added product string in the function, is this possible one way or another?
console.log("after r : " + r)
let endResult = ((100-r)/100) *parseFloat(prijs)
console.log("after endResult : " + endResult)
return endResult
}).catch((Err)=>{
let r = 0
return 0
})
}
the reason i would like this is so i don’t have to make an if else statement in my function.
if product === X do …else if product === Y do … else if product === Z do …
the product string i add doesn’t have to many variations but if i can make it shorter its always better.
kind regards
Kristof.