Environment
Laravel v9 + vite, PHP 8.1, vue3, VPS linux distro. UBUNTU
I am having this error in the vue.js component of my Laravel project,it says that the profile_picture has a null value in the object but I also put the check for this
<div v-if="typeof rep.user.profile_picture != null">
<img :src="rep.user.profile_picture" :alt="rep.user.name" class="commenter-image rounded-circle"/>
</div>
<div v-else>
<img src="/assets/images/user-placeholder-1.jpg" alt="Commenter-placeholder" class="commenter-image rounded-circle"/>
</div>
I have carefully searched for this profile_picture property in the file it’s not anywhere else except this. but still having this issue
also, it doesn’t have any relation with the sweetalert2 library but still, console is pointing to this library
Any thoughts about this error??
extra help meterial>>
2
Answers
The condition
v-if="typeof rep.user.profile_picture != null"
doesn’t work becausetypeof rep.user.profile_picture
returnsobject
. So I would suggest you to change this condition toor even
Looks like in some
rep
objects,user
property is null. Can you please verify that all the objects in an array contains a value inuser
property.You can use
optional chaining (?.)
operator :