diff --git a/src/plugins/restService.js b/src/plugins/restService.js new file mode 100644 index 0000000..f66b65e --- /dev/null +++ b/src/plugins/restService.js @@ -0,0 +1,18 @@ +import axios from 'axios' + +class Service { + constructor(url) { + this.url = url + } + getFinanzerMain(token) { + return axios.get(this.url + "getFinanzerMain", {headers: {Token: token}}) + + } + login(loginData) { + return axios.post(this.url+'login', {...loginData}) + } +} + +const httpClient = new Service("http://192.168.5.118:5000/") + +export default httpClient diff --git a/src/store/index.js b/src/store/index.js index bbf678d..b4e0d3e 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -1,12 +1,10 @@ import Vue from 'vue' import Vuex from 'vuex' import router from "@/router"; -import axios from 'axios' +import httpClient from "../plugins/restService"; Vue.use(Vuex) -const url = 'http://localhost:5000/' - export default new Vuex.Store({ state: { user: { @@ -53,7 +51,7 @@ export default new Vuex.Store({ // eslint-disable-next-line no-console console.log("loginData:", loginData) commit('loginStart'); - axios.post(url+'login', {...loginData}) + httpClient.login(loginData) .then(response => { localStorage.setItem('user', JSON.stringify({ username: response.data.username, accessToken: response.data.token, group: response.data.group})); commit('loginStop', null); diff --git a/src/views/FinanzerView.vue b/src/views/FinanzerView.vue index d4205ed..2a80ef1 100644 --- a/src/views/FinanzerView.vue +++ b/src/views/FinanzerView.vue @@ -16,7 +16,7 @@