renaming gifs, adding create post element
This commit is contained in:
32
nginx/vue/src/components/admin/CreatePost.vue
Normal file
32
nginx/vue/src/components/admin/CreatePost.vue
Normal file
@@ -0,0 +1,32 @@
|
||||
<script setup>
|
||||
import { ref, onMounted, computed } from "vue";
|
||||
import axios from "axios";
|
||||
import { useAuthStore } from "@/stores/auth";
|
||||
|
||||
const auth = useAuthStore();
|
||||
const title = ref("");
|
||||
const content = ref("");
|
||||
|
||||
async function post() {
|
||||
try {
|
||||
const res = await axios.post("/api/posts", {
|
||||
title: title.value,
|
||||
content: content.value,
|
||||
});
|
||||
title.value = "";
|
||||
content.value = "";
|
||||
console.log(res.data);
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div v-if="auth.loggedIn">
|
||||
<h1>Create Post</h1>
|
||||
<input type="text" v-model="title" placeholder="Title" />
|
||||
<textarea v-model="content" placeholder="Content"></textarea>
|
||||
<button @click="post">Upload</button>
|
||||
</div>
|
||||
</template>
|
||||
Reference in New Issue
Block a user