Fajar
392
4
Laravel

Vue warn Error in render: "TypeError: Cannot read property 'link' of undefined"

Posted 7 months ago by Fajar

Hay, I'm trying to make a notification using vue I get a message when I type $ vm0.notifications = ['adf'];

this is the message In rendering error: "TypeError: Cannot read property 'link' of undefined"

found on UserNotifications.vue

can you help me where is my fault thank you

UserNotifications.vue

  •   Notifications

        <ul class="dropdown-menu dropdown-menu-right"  >
            <li v-for="notification in notifications">
    
                <a class="dropdown-item" :href="notification.data.link"
                    v-text="notification.data.message"
                    @click="markAsRead(notification)"
                >
                
                </a>
                
            </li>
        </ul>
    </li>
    

    export default {
        data() {
    
            return { notifications: false }
    
        },
    
        created() {
    
            axios.get('/profiles/' + window.App.user.name + '/notifications')
                 .then(response => this.notifications = response.data);
    
        },
    
        methods: {
    
            markAsRead(notification) {
    
                axios.delete('/profiles/' + window.App.user.name + '/notifications/' + notification.id)
    
            }
    
        }
    
    }
    

    TreadWasUpdated.php public function toArray($notifiable) { return [ 'message' => $this->reply->owner->name . 'replied to ' . $this->thread->title, 'link' => $this->reply->path() ]; }

  • Please sign in or create an account to participate in this conversation.

    Reply to

    Use Markdown with GitHub-flavored code blocks.