This commit is contained in:
@@ -14,7 +14,7 @@ export default {
|
|||||||
json(response) {
|
json(response) {
|
||||||
return response.json();
|
return response.json();
|
||||||
},
|
},
|
||||||
PatchAuthorizedHeaders() {
|
patchAuthorizedHeaders() {
|
||||||
return {
|
return {
|
||||||
//Accept: "application/json, text/plain, */*",
|
//Accept: "application/json, text/plain, */*",
|
||||||
Accept: "application/json",
|
Accept: "application/json",
|
||||||
@@ -22,14 +22,14 @@ export default {
|
|||||||
Authorization: "Bearer " + store.state.apiToken
|
Authorization: "Bearer " + store.state.apiToken
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
PostAuthorizedHeaders() {
|
postAuthorizedHeaders() {
|
||||||
return {
|
return {
|
||||||
Accept: "application/json",
|
Accept: "application/json",
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
Authorization: "Bearer " + store.state.apiToken
|
Authorization: "Bearer " + store.state.apiToken
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
PostUnAuthorizedHeaders() {
|
postUnAuthorizedHeaders() {
|
||||||
return {
|
return {
|
||||||
Accept: "application/json",
|
Accept: "application/json",
|
||||||
"Content-Type": "application/json"
|
"Content-Type": "application/json"
|
||||||
@@ -39,11 +39,19 @@ export default {
|
|||||||
return {
|
return {
|
||||||
method: "post",
|
method: "post",
|
||||||
mode: "cors",
|
mode: "cors",
|
||||||
headers: this.PostUnAuthorizedHeaders(),
|
headers: this.postUnAuthorizedHeaders(),
|
||||||
body: JSON.stringify(data)
|
body: JSON.stringify(data)
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
APIUrl() {
|
fetchPost(data) {
|
||||||
return store.state.apiUrl;
|
return {
|
||||||
|
method: "post",
|
||||||
|
mode: "cors",
|
||||||
|
headers: this.postAuthorizedHeaders(),
|
||||||
|
body: JSON.stringify(data)
|
||||||
|
};
|
||||||
|
},
|
||||||
|
APIUrl(apiPath) {
|
||||||
|
return store.state.apiUrl + apiPath;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import { processLogin, processLogout } from "../utils/authutil";
|
|||||||
export default {
|
export default {
|
||||||
async authenticate(login, password) {
|
async authenticate(login, password) {
|
||||||
return fetch(
|
return fetch(
|
||||||
apiUtil.APIUrl() + "auth",
|
apiUtil.APIUrl("auth"),
|
||||||
apiUtil.fetchPostNoAuth({
|
apiUtil.fetchPostNoAuth({
|
||||||
login: login,
|
login: login,
|
||||||
password: password
|
password: password
|
||||||
|
|||||||
@@ -13,23 +13,18 @@ export default {
|
|||||||
fetch(keys) {
|
fetch(keys) {
|
||||||
return new Promise(function(resolve, reject) {
|
return new Promise(function(resolve, reject) {
|
||||||
//step 1: build an array of keys that we don't have already
|
//step 1: build an array of keys that we don't have already
|
||||||
var NeedIt = [];
|
var needIt = [];
|
||||||
for (var i = 0; i < keys.length; i++) {
|
for (var i = 0; i < keys.length; i++) {
|
||||||
if (!_.has(store.state.localeText, keys[i])) {
|
if (!_.has(store.state.localeText, keys[i])) {
|
||||||
NeedIt.push(keys[i]);
|
needIt.push(keys[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (NeedIt.length == 0) {
|
if (needIt.length == 0) {
|
||||||
resolve();
|
resolve();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//step 2: get it
|
//step 2: get it
|
||||||
fetch(apiUtil.APIUrl() + "locale/subset", {
|
fetch(apiUtil.APIUrl("locale/subset"), apiUtil.fetchPost(needIt))
|
||||||
method: "post",
|
|
||||||
mode: "cors",
|
|
||||||
headers: apiUtil.PostAuthorizedHeaders(),
|
|
||||||
body: JSON.stringify(NeedIt)
|
|
||||||
})
|
|
||||||
.then(apiUtil.status)
|
.then(apiUtil.status)
|
||||||
.then(apiUtil.json)
|
.then(apiUtil.json)
|
||||||
.then(response => {
|
.then(response => {
|
||||||
|
|||||||
Reference in New Issue
Block a user