Skip to content

Commit

Permalink
remove fetch / use axios fix #1077
Browse files Browse the repository at this point in the history
  • Loading branch information
hay-kot committed Mar 23, 2022
1 parent 20822ee commit b10ce50
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions frontend/composables/api/use-app-info.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
import { onMounted, ref, Ref } from "@nuxtjs/composition-api";
import { ref, Ref, useAsync, useContext } from "@nuxtjs/composition-api";
import { useAsyncKey } from "../use-utils";
import { AppInfo } from "~/types/api-types/admin";

export function useAppInfo(): Ref<AppInfo | null> {
const appInfo = ref<null | AppInfo>(null);

onMounted(async () => {
const data = await fetch("/api/app/about").then((res) => res.json());
appInfo.value = data as AppInfo;
});
const { $axios } = useContext();

useAsync(async () => {
const data = await $axios.get<AppInfo>("/api/app/about");
appInfo.value = data.data;
}, useAsyncKey());

return appInfo;
}

0 comments on commit b10ce50

Please sign in to comment.