feat: use axios, extract api to another file

This commit is contained in:
wancat committed 2023-08-01 20:54:49 +08:00
1 parent a40e9eb3a9
commit 66cc1036b4
4 files changed
+59 -5

No files matched your search

+6 -4
View File
@@ -1,13 +1,15 @@
<script setup>
import { ref } from 'vue'
import api from '../utils/api'
const questData = ref(null)
const questErr = ref(null)
fetch('https://odyssey.wancat.cc/api/v1/quests/helloworld')
.then((res) => res.json())
.then((json) => {
questData.value = JSON.stringify(json.content)
api
.get('/quests/helloworld')
.then((res) => {
console.log(res.data)
questData.value = JSON.stringify(res.data.content)
})
.catch((err) => {
questErr.value = err