Just starting out with Vue.js, I stumbled upon a Medium article about the MEVN architecture. Here's a snippet of code from a component that I've been working on for the past two days:
<template>
<div class="post">
<h1>post</h1>
<div>
<!-- <p v-for="post in posts">
<span><b>{{post.title}}</b></span>
<span><b>{{post.description}}</b></span>
</p> -->
</div>
</div>
</template>
<script>
import postService from "@/services/postservice";
export default {
name: 'posts',
data() {
return {
posts: []
}
},
mounted() {
this.getPosts()
},
methods: {
async getPosts() {
const response = await postService.fetchPost()
this.posts = response.data
}
}
}
</script>
<style scoped>
</style>
Here's the terminal output: