This commit is contained in:
2020-09-09 13:46:43 +00:00
parent 0b4e215a33
commit 4234908f6a

View File

@@ -50,17 +50,14 @@ var ayTranslationKeyCache = {};
// GET TRANSLATIONS FROM API SERVER // GET TRANSLATIONS FROM API SERVER
// //
async function ayGetTranslations(keys) { async function ayGetTranslations(keys) {
if (!keys || keys.length == 0) {
return;
}
try { try {
let r = await fetch(route, { let transData = await ayPostToAPI("translation/subset", keys);
method: "get", transData.data.forEach(function storeFetchedTranslationItemsInCache(item) {
mode: "cors", ayTranslationKeyCache[item.key] = item.value;
headers: {
Accept: "application/json",
"Content-Type": "application/json",
Authorization: token
}
}); });
return await r.json();
} catch (error) { } catch (error) {
//fundamental error, can't proceed with this call //fundamental error, can't proceed with this call
// handleError("GET", error, route); // handleError("GET", error, route);
@@ -74,7 +71,7 @@ async function ayGetTranslations(keys) {
// //
async function ayGetFromAPI(route, token) { async function ayGetFromAPI(route, token) {
token = token || AYMETA.ayClientMetaData.Authorization; token = token || AYMETA.ayClientMetaData.Authorization;
if(route && !route.startsWith("http")){ if (route && !route.startsWith("http")) {
route = AYMETA.ayServerMetaData.ayApiUrl + route; route = AYMETA.ayServerMetaData.ayApiUrl + route;
} }
try { try {
@@ -101,7 +98,7 @@ async function ayGetFromAPI(route, token) {
// //
async function ayPostToAPI(route, data, token) { async function ayPostToAPI(route, data, token) {
token = token || AYMETA.ayClientMetaData.Authorization; token = token || AYMETA.ayClientMetaData.Authorization;
if(route && !route.startsWith("http")){ if (route && !route.startsWith("http")) {
route = AYMETA.ayServerMetaData.ayApiUrl + route; route = AYMETA.ayServerMetaData.ayApiUrl + route;
} }
try { try {