-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
414aae8
commit 297ac7b
Showing
7 changed files
with
183 additions
and
7 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import {ref} from "vue"; | ||
import axios from "axios"; | ||
|
||
export default function usePosts() { | ||
const posts = ref([]); | ||
|
||
const fetchPosts = async () => { | ||
let response = await axios.get('/api/posts'); | ||
|
||
posts.value = response.data.data | ||
} | ||
|
||
return { | ||
posts, | ||
fetchPosts | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,9 @@ | ||
import { createApp } from 'vue' | ||
import './style.css' | ||
import App from './App.vue' | ||
import router from "./router/index.js"; | ||
import axios from "axios"; | ||
|
||
createApp(App).mount('#app') | ||
axios.defaults.baseURL = 'http://localhost:8000'; | ||
|
||
createApp(App).use(router).mount('#app') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<script setup> | ||
import {onMounted} from "vue"; | ||
import usePosts from "../api/usePosts.js"; | ||
const {posts, fetchPosts} = usePosts() | ||
onMounted(fetchPosts) | ||
</script> | ||
|
||
<template> | ||
<div class="space-y-16"> | ||
<div | ||
v-for="post in posts" | ||
:key="post.uuid" | ||
> | ||
<a href="" class="block"> | ||
<h1 class="text-3xl sm:text-4xl leading-10 font-extrabold tracking-tight text-gray-900">{{ post.title }}</h1> | ||
<p class="mt-6 text-gray-500"> | ||
{{ post.teaser }} | ||
</p> | ||
</a> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<style scoped> | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { createRouter, createWebHistory } from "vue-router"; | ||
import Home from "../pages/Home.vue"; | ||
|
||
const routes = [ | ||
{ | ||
path: '/', | ||
name: 'home', | ||
component: Home | ||
} | ||
] | ||
|
||
export default createRouter({ | ||
history: createWebHistory(), | ||
routes | ||
}) |