feat: add error handling for data cascade

This commit is contained in:
Devin Haska 2024-05-24 12:55:31 -07:00
parent c293a63d9b
commit 896c86d9d2
No known key found for this signature in database
5 changed files with 185 additions and 56 deletions

View file

@ -9,10 +9,23 @@ const relativeTime = require("dayjs/plugin/relativeTime");
dayjs.extend(utc);
dayjs.extend(relativeTime);
const fetchRecentMovies = async () => {
const url = `https://letterboxd.com/wonderfulfrog/rss/`;
const fetchLetterboxd = async (duration) => {
try {
const url = `https://letterboxd.com/wonderfulfrog/rss/`;
const response = await EleventyFetch(url, { duration, type: "text" });
return response;
} catch (e) {
console.error("Error fetching data from Letterboxd", e);
return undefined;
}
};
const response = await EleventyFetch(url, { duration: "1d", type: "text" });
const fetchRecentMovies = async () => {
const response = await fetchLetterboxd("1d");
if (!response) {
return [];
}
const $ = cheerio.load(response, { xml: true });