Make aggregator failsafe
This commit is contained in:
parent
a44e7c9594
commit
20f12eb9bc
1 changed files with 13 additions and 2 deletions
|
@ -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');
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue