replace all $fetch with useRequestFetch

This commit is contained in:
Wroclaw 2023-12-20 05:45:29 +01:00
parent 015b66706f
commit eabb7b89c7
5 changed files with 22 additions and 22 deletions

View file

@ -1,11 +1,11 @@
<script setup lang="ts">
/* global $fetch */
import { ref, watch } from "vue";
import { VForm } from "vuetify/components";
import { cookieSettings } from "~/utils/cookieSettings";
import { definePageMeta, navigateTo, useCookie, useFetch, useRoute } from "#imports";
import { definePageMeta, navigateTo, useCookie, useFetch, useRoute, useRequestFetch } from "#imports";
const route = useRoute();
const fetch = useRequestFetch();
const login = ref("");
const password = ref("");
@ -24,7 +24,7 @@ definePageMeta({
async function submit() {
loading.value = true;
try {
const result = await $fetch("/api/login", {
const result = await fetch("/api/login", {
body: { login: login.value, password: password.value },
method: "POST",
});
@ -44,7 +44,7 @@ async function submit() {
async function logout() {
try {
await $fetch("/api/logout");
await fetch("/api/logout");
loggedIn.value = false;
} catch (e) {
console.error(e);
@ -56,7 +56,7 @@ watch(loggedIn, updateUserInfo);
async function updateUserInfo() {
if (loggedIn.value) {
try {
userInfo.value = JSON.stringify(await $fetch("/api/users/me"));
userInfo.value = JSON.stringify(await fetch("/api/users/me"));
} catch (e) {
// expected if the user is not logged in
userInfo.value = "";