Merge pull request 'Make aggregator failsafe' (#2) from fix-instagram into main

Reviewed-on: #2
This commit is contained in:
Kevin Kandlbinder 2024-12-27 22:10:07 +01:00
commit 5c9e2e8798

View file

@ -32,8 +32,17 @@ const compareContentDate = (a: Content, b: Content) => {
export const aggregateContent = async () => {
let content: Content[] = [];
content.push(...(await fetchInstagramContent()));
content.push(...(await fetchBlogPosts()));
try {
content.push(...(await fetchInstagramContent()));
} catch(e) {
console.error("Unable to fetch instagram content: ", e)
}
try {
content.push(...(await fetchBlogPosts()));
} catch(e) {
console.error("Unable to fetch ghost content: ", e)
}
content.sort(compareContentDate);
@ -62,6 +71,7 @@ export const fetchBlogPosts = async () => {
throw 'Not Found';
}
} catch (e) {
console.error(e)
throw new Error('Failed to communicate with Ghost');
}
@ -95,6 +105,7 @@ export const fetchInstagramContent = async () => {
);
if (!response.ok) {
console.error(response.status)
throw new Error('Failed to communicate with Instagram');
}