[Vuejs]-MongoDB _id returns undefined on frontend (VueJS)

0👍

You need to add the property reference post, like this:

<div class="post" v-for="(post,i) in posts " :key="post._id" :post="post" @dblclick="deletePost(post._id)">
        {{post.createdAt.getDate()}}/{{post.createdAt.getMonth() + 1}}/{{post.createdAt.getFullYear()}}
        <p class="text">{{post.text}}</p>
      </div>

0👍

You don’t have to convert _id to Mongo ObjectID on the FrontEND.

Your code looks normal, send all post object to function like that and debug it.

@dblclick=”deletePost(post)”

Probably your backend return _id as an object.

Leave a comment