mirror of
https://github.com/Spythere/station-manager-2.0.git
synced 2026-05-03 13:38:13 +00:00
axios: baseURL
This commit is contained in:
+4
-19
@@ -23,7 +23,6 @@
|
||||
<script lang="ts">
|
||||
import axios from 'axios';
|
||||
import { defineComponent } from 'vue';
|
||||
import dataMixin from '../mixins/dataMixin';
|
||||
import { useStore } from '../store';
|
||||
import { AuthState, ILoginResponse } from '../types/types';
|
||||
|
||||
@@ -34,8 +33,6 @@ enum LoginState {
|
||||
}
|
||||
|
||||
export default defineComponent({
|
||||
mixins: [dataMixin],
|
||||
|
||||
data() {
|
||||
return {
|
||||
errorMessage: '',
|
||||
@@ -61,31 +58,19 @@ export default defineComponent({
|
||||
console.log('Ładowanie');
|
||||
|
||||
try {
|
||||
const data: ILoginResponse = (
|
||||
await axios.post(
|
||||
`${this.API_URL}/auth/login`,
|
||||
{ username: this.name, password: this.password },
|
||||
{
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
}
|
||||
)
|
||||
).data;
|
||||
const loginData = (await this.store.login(this.name, this.password)).data;
|
||||
|
||||
this.store.authState = AuthState.AUTHORIZED;
|
||||
this.loginState = LoginState.LOADED;
|
||||
|
||||
this.store.token = data.token;
|
||||
this.store.user = data.user;
|
||||
this.store.token = loginData.token;
|
||||
this.store.user = loginData.user;
|
||||
|
||||
window.localStorage.setItem('auth-token', this.store.token);
|
||||
window.localStorage.setItem('user', JSON.stringify(this.store.user));
|
||||
|
||||
console.log('Gituwa');
|
||||
|
||||
this.$router.push('/');
|
||||
this.loadData();
|
||||
this.store.fetchSceneriesData();
|
||||
} catch (e: any) {
|
||||
this.store.authState = AuthState.UNAUTHORIZED;
|
||||
this.loginState = LoginState.LOADED;
|
||||
|
||||
@@ -58,7 +58,6 @@
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
import changeMixin from '../mixins/changeMixin';
|
||||
import dataMixin from '../mixins/dataMixin';
|
||||
import { useStore } from '../store';
|
||||
import { SceneryRowItem, Availability, AuthState } from '../types/types';
|
||||
import RoutesModal from '../components/RoutesModal.vue';
|
||||
@@ -68,7 +67,7 @@ import UpdateCard from '../components/UpdateCard.vue';
|
||||
|
||||
export default defineComponent({
|
||||
components: { RoutesModal, TableActions, UpdateCard },
|
||||
mixins: [dataMixin, changeMixin, routesMixin],
|
||||
mixins: [changeMixin, routesMixin],
|
||||
|
||||
data: () => ({
|
||||
AuthState,
|
||||
@@ -97,7 +96,7 @@ export default defineComponent({
|
||||
},
|
||||
|
||||
mounted() {
|
||||
this.loadData();
|
||||
this.store.fetchSceneriesData();
|
||||
},
|
||||
|
||||
computed: {
|
||||
|
||||
Reference in New Issue
Block a user