I have a collection of images (selfies) that I would like to display on a page. Here is my code but it is not working. (I cannot simply just link the page to the collection because the page is already dynamically linked with another collection)
Â
wixData.query("Selfie")
.eq("playerName", ($w("#playerName").text).toString())
.find()
.then((results) => {
let item = (results.items[0]);
if (item.selfie === undefined) {
Â
} else {
$w("#selfieImage").src = (item.selfie);
}
});
}
Â
I would like the image on the page to be set to its default image if the player has not already added their picture, but if they have I want the picture to be retrieved from the collection Selfie (playerName is unique).
Â
Thanks in advance!
Â
Â
Hey,
Â
I've checked the code - actually it works for me.
Â
Could you tell me more what is not working? What is the flow now?
Â
You can also add .catch to catch and log an error:
Â
Â
Â
Â
Also, what is the element here: $w("#playerName").text ? Is this text label on your page?
Â
Â
Thanks for your reply!
I deleted the code, then copied it back in and it them worked.
Not sure why it wasn't working yesterday.
Â
Thanks for verifying that it was correct!