Skip to content

Commit

Permalink
reverted
Browse files Browse the repository at this point in the history
  • Loading branch information
panteLx committed Jun 4, 2024
1 parent 410741b commit 58a2b3b
Showing 1 changed file with 18 additions and 21 deletions.
39 changes: 18 additions & 21 deletions js/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ function sendRequest() {

const statusEndpoint = "factory/list";
const bearerTokenLab = "7YC9YM41X63SG52ZDL";
// const bearerTokenCar = "F9UKIAKBZDHWY6H6JG"; OLD
// const bearerTokenCar = "F9UKIAKBZDHWY6H6JG";
const bearerTokenCar = "7YC9YM41X63SG52ZDL";
const corsAnywhereUrl = "https://statevproxy.pantelx.com/"; // CORS Proxy - Fliegt bei IC Website raus

Expand All @@ -26,26 +26,23 @@ function sendRequest() {
if (cache[endpoint] && Date.now() - cache[endpoint].timestamp < 600000) {
return Promise.resolve(cache[endpoint].data);
} else {
return (
fetch(apiUrl + endpoint, config)
//return fetch(corsAnywhereUrl + apiUrl + endpoint, config)
.then((response) => {
if (!response.ok) {
throw new Error("Network response was not ok");
}
return response.json();
})
.then((data) => {
// Daten im Cache speichern mit Zeitstempel
cache[endpoint] = { data: data, timestamp: Date.now() };
saveCacheToLocalStorage(); // Cache im Local Storage speichern
return data;
})
.catch((error) => {
console.error("Fehler beim Senden der Anfrage:", error);
return { error: true };
})
);
return fetch(corsAnywhereUrl + apiUrl + endpoint, config)
.then((response) => {
if (!response.ok) {
throw new Error("Network response was not ok");
}
return response.json();
})
.then((data) => {
// Daten im Cache speichern mit Zeitstempel
cache[endpoint] = { data: data, timestamp: Date.now() };
saveCacheToLocalStorage(); // Cache im Local Storage speichern
return data;
})
.catch((error) => {
console.error("Fehler beim Senden der Anfrage:", error);
return { error: true };
});
}
};

Expand Down

0 comments on commit 58a2b3b

Please sign in to comment.