axios: baseURL

This commit is contained in:
2023-02-10 14:42:11 +01:00
parent 446698b832
commit 580e109dda
7 changed files with 86 additions and 98 deletions
+4 -8
View File
@@ -6,23 +6,20 @@
<script lang="ts">
import { defineComponent } from 'vue';
import dataMixin from './mixins/dataMixin';
import PopUpCard from './components/PopUpCard.vue';
import axios from 'axios';
import { RouterView } from 'vue-router';
import { IUser, AuthState } from './types/types';
import { AuthState } from './types/types';
import useRouteGuard from './mixins/useRouteGuard';
import { useStore } from './store';
import useLocalStorage from './mixins/useLocalStorage';
export default defineComponent({
mixins: [dataMixin],
components: { PopUpCard },
setup() {
const { routeAuthGuard } = useRouteGuard();
const { setupStorage } = useLocalStorage();
routeAuthGuard();
setupStorage();
@@ -41,9 +38,8 @@ export default defineComponent({
this.store.token = token;
const data = axios.post<{ user: IUser }>(`${this.API_URL}/auth/token`, { token: this.store.token });
data
this.store
.fetchTokenData()
.then((res) => {
this.store.user = res.data.user;
this.store.authState = AuthState.AUTHORIZED;