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 () => {
|
export const aggregateContent = async () => {
|
||||||
let content: Content[] = [];
|
let content: Content[] = [];
|
||||||
|
|
||||||
|
try {
|
||||||
content.push(...(await fetchInstagramContent()));
|
content.push(...(await fetchInstagramContent()));
|
||||||
|
} catch(e) {
|
||||||
|
console.error("Unable to fetch instagram content: ", e)
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
content.push(...(await fetchBlogPosts()));
|
content.push(...(await fetchBlogPosts()));
|
||||||
|
} catch(e) {
|
||||||
|
console.error("Unable to fetch ghost content: ", e)
|
||||||
|
}
|
||||||
|
|
||||||
content.sort(compareContentDate);
|
content.sort(compareContentDate);
|
||||||
|
|
||||||
|
@ -62,6 +71,7 @@ export const fetchBlogPosts = async () => {
|
||||||
throw 'Not Found';
|
throw 'Not Found';
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
console.error(e)
|
||||||
throw new Error('Failed to communicate with Ghost');
|
throw new Error('Failed to communicate with Ghost');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,6 +105,7 @@ export const fetchInstagramContent = async () => {
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
|
console.error(response.status)
|
||||||
throw new Error('Failed to communicate with Instagram');
|
throw new Error('Failed to communicate with Instagram');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue