This commit is contained in:
2018-11-09 21:18:38 +00:00
parent 943cd0875d
commit c2ff9d4ae5

View File

@@ -23,8 +23,19 @@ Methods
const lt = {}; const lt = {};
export default { export default {
async Get(keys) {}, async Get(keys) {
this.PreFetch(keys);
//TODO: return they keys / lt array
},
async PreFetch(keys) { async PreFetch(keys) {
//step 1: build an array of keys that we don't have already
var NeedIt = [];
keys.forEach(key => {
if (!has(lt, key)) {
NeedIt.push(key);
}
});
//todo: make this work with the locale route to get teh batch of keys and store into the lt object //todo: make this work with the locale route to get teh batch of keys and store into the lt object
fetch(config.apiUrl + "auth", { fetch(config.apiUrl + "auth", {
method: "post", method: "post",
@@ -34,18 +45,17 @@ export default {
"Content-Type": "application/json" "Content-Type": "application/json"
}, },
body: JSON.stringify({ body: JSON.stringify({
login: login, login: "",
password: password password: ""
}) })
}) })
.then(api.status) .then(api.status)
.then(api.json) .then(api.json)
.then(processLogin)
.then(() => { .then(() => {
return Promise.resolve(true); return Promise.resolve(true);
}) //succeeded, nothing to return }) //succeeded, nothing to return
.catch(function(error) { .catch(function(error) {
processLogout();
return Promise.reject(error); return Promise.reject(error);
}); });
}, },