Return empty list if no instances could be fetched
This commit is contained in:
parent
2871f3f6e8
commit
808ab27ed4
|
@ -6,6 +6,7 @@
|
||||||
import { APIRoute } from "astro";
|
import { APIRoute } from "astro";
|
||||||
|
|
||||||
export const get: APIRoute = async () => {
|
export const get: APIRoute = async () => {
|
||||||
|
try {
|
||||||
const response = await fetch("https://api.joinmastodon.org/servers");
|
const response = await fetch("https://api.joinmastodon.org/servers");
|
||||||
const instances = await response.json();
|
const instances = await response.json();
|
||||||
|
|
||||||
|
@ -18,4 +19,12 @@ export const get: APIRoute = async () => {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Could not fetch instances:", error);
|
||||||
|
return new Response(JSON.stringify([]), {
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue