🔨 Replaces native fetch with axios
All checks were successful
Gitea Build Action / build-go (push) Successful in 25s
Gitea Build Action / build-nuxt (push) Successful in 10m20s

This commit is contained in:
Daniel Svitan
2025-06-06 22:33:26 +02:00
parent 88c31a5133
commit ae7db8290c
6 changed files with 95 additions and 59 deletions

View File

@@ -22,6 +22,7 @@
<script lang="ts" setup>
import * as v from "valibot"
import type { FormSubmitEvent } from "@nuxt/ui"
import axios from "axios"
const token = useToken()
@@ -35,20 +36,20 @@ const state = reactive({
})
const toast = useToast()
async function onSubmit(event: FormSubmitEvent<Schema>) {
function onSubmit(event: FormSubmitEvent<Schema>) {
const received = event.data.token
await $fetch(useAPI("/open"), {
method: "GET",
headers: {
Authorization: `Bearer ${received}`,
},
onRequestError: handleRequestError,
onResponse: handleResponse(() => {
toast.add({ title: "Token saved", color: "success" })
token.value = received
navigateTo("/")
}),
})
axios
.get<boolean>(useAPI("/open"), {
headers: useHeaders(received),
})
.then((res) => {
handleResponse(res, () => {
toast.add({ title: "Token saved", color: "success" })
token.value = received
navigateTo("/")
})
})
.catch(handleRequestError)
}
onMounted(() => {