Skip to content

Commit

Permalink
fix: oups detection API (bis)
Browse files Browse the repository at this point in the history
  • Loading branch information
dhdaines committed Oct 15, 2024
1 parent 6a5f562 commit 9d2a889
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class App {
});
// Load stuff
const placeholder = document.getElementById("placeholder")!;
let result = { ok: false };
let result = null;
try {
result = await fetch(`${ALEXI_API}/villes`);
if (result.ok) {
Expand All @@ -95,8 +95,8 @@ class App {
catch {
console.log("Failed to contact API, falling back to client-side search");
}
if (!result.ok) {
let result = await fetch(`${ALEXI_URL}/_idx/index.json`);
if (result === null || !result.ok) {
result = await fetch(`${ALEXI_URL}/_idx/index.json`);
if (result.ok) {
this.index = lunr.Index.load(await result.json());
if (placeholder !== null)
Expand All @@ -109,7 +109,7 @@ class App {
}
}
}
if (placeholder !== null && !result.ok) {
if (placeholder !== null && (result === null || !result.ok)) {
placeholder.innerText = `Erreur de chargement (index ou documents): ${result.statusText}`;
return;
}
Expand Down

0 comments on commit 9d2a889

Please sign in to comment.