I’m trying grab a random record from a collection and display the image (from a field in the record) in an Image control. The random bit seems to be working ok.
I see the path to the image but non of my other fields.
export function button1_click(event) {
wixData.query(“Images”)
.find()
.then( (results) => {
let randomNumber = Math.floor((Math.random() * results.items.length));
console.log(randomNumber)
let randomItem = results.items[randomNumber];
console.log(randomItem)
$w(“#image1”).src = randomItem.Image;
console.log(“ok”)
}); //Add your code for this event here:
}
Any ideas ?