Currently, I am utilizing Vue.js 3 for my project, however, I do not believe this is the root cause of the issue I am facing. The problem lies in my attempt to access a JSON array of post objects stored in localStorage. After parsing the array and extracting the id from the route, I use the .find method to search for the corresponding post object. Unfortunately, the search operation seems to be returning undefined.
Within the Post.vue file
created() {
this.postId = this.$route.params.id;
console.log("****** POST ID *******");
console.log(this.postId);
var posts = JSON.parse(localStorage.getItem("posts"));
console.log("****** POSTS ARRAY *******");
console.log(posts);
this.post = posts.find(post => post.id === this.postId);
console.log("****** POST *******");
console.log(this.post);
}