This commit is contained in:
2018-11-14 18:19:59 +00:00
parent e4991bdade
commit 06312793a9
7 changed files with 31 additions and 19 deletions

View File

@@ -19,5 +19,8 @@ export default {
"Content-Type": "application/json",
Authorization: "Bearer " + store.state.apiToken
};
},
APIUrl() {
return store.state.apiUrl;
}
};

View File

@@ -1,10 +1,9 @@
import config from "../utils/config";
import api from "./apiutil";
import apiUtil from "./apiutil";
import { processLogin, processLogout } from "../utils/authutil";
export default {
async authenticate(login, password) {
return fetch(config.apiUrl + "auth", {
return fetch(apiUtil.APIUrl + "auth", {
method: "post",
mode: "cors",
headers: {
@@ -16,8 +15,8 @@ export default {
password: password
})
})
.then(api.status)
.then(api.json)
.then(apiUtil.status)
.then(apiUtil.json)
.then(processLogin)
.then(() => {
return Promise.resolve(true);

View File

@@ -1,7 +1,6 @@
/* xeslint-disable */
import store from "../store";
import config from "../utils/config";
import api from "./apiutil";
import apiUtil from "./apiutil";
import _ from "../utils/libs/core.min.js";
export default {
@@ -24,14 +23,14 @@ export default {
resolve();
return;
}
fetch(config.apiUrl + "locale/subset", {
fetch(apiUtil.APIUrl + "locale/subset", {
method: "post",
mode: "cors",
headers: api.AuthorizedHeaders(),
headers: apiUtil.AuthorizedHeaders(),
body: JSON.stringify(NeedIt)
})
.then(api.status)
.then(api.json)
.then(apiUtil.status)
.then(apiUtil.json)
.then(response => {
_.forEach(response.data, function(item) {
store.commit("addLocaleText", item);