I have a collection one item in the list is an Image and if the image object in the collection is null it should show a static picture and if image is available then show it from original. I’ve learned that if condition is a function and therefore I will get “Cannot read properties of null (reading ‘url’)”.
But How can I do it with real if else statement?
The error message you provided states that the object
null, but your condition is on
context.item.data[‘image’]. Have you confirmed that the latter is
null as well?
You might want to check for
=="" too (although probably not the issue here).
Also, it seems you’re getting this data from the page context, not a collection directly. Is this expected?
context.item.[...] is pointing to the page context, not a collection if I’m not mistaken.
It is a collection and I’ll define the rule for the second element that’s a image. if item.data[‘image’] is null then I would like to show a static image
Most of the things in WeWeb are intuitiv and I could figure it out by myself!
I love WeWeb and the awesome support!!!
TX so much it is working
Maybe you could also try to reverse the condition :
If (item.date['image'], item.date['image']['url'], “...trainer_man_people_avatar_person_icon_224822.png”)