I have developed another Vue.js admin page specifically for "writer" where I can display post data fetched from a MySQL database. The admin page called "admin" is functioning properly and responding with all the necessary data.
The following code snippet shows how I want to fetch and display the post data on the Posts page:
<template>
<div>
<h1>POSTS</h1>
<section class="posts-page">
<div v-for="post in posts" :key="post.id">
{{ post }}
</div>
</section>
</div>
</template>
<script>
export default {
data() {
return {
posts: []
}
},
created() {
axios.get('/api/posts/').then(console.table())
}
}
</script>
<style>
Here is the API PostController.php code snippet that handles fetching posts:
public function index()
{
return Post::with('user')->latest('id')->get();
}
Thank you for your assistance.