From 3bbaeb2048cccc0d7704d1ec1d1b721294152745 Mon Sep 17 00:00:00 2001 From: Ryan Mwangi Date: Wed, 23 Oct 2024 15:52:43 +0300 Subject: [PATCH] edit updateMergedCalendars function to read from the calendarFile --- server.js | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/server.js b/server.js index 5090100..db090a7 100644 --- a/server.js +++ b/server.js @@ -164,17 +164,10 @@ async function updateMergedCalendars(calendarId){ try { // Load calendar data from the individual JSON file const calendarFile = `${MERGED_CALENDARS_DIR}/${calendarId}.json`; - const calendarsData = JSON.parse(fs.readFileSync(calendarFile, 'utf8')); - - // Find the merged calendar with the specified ID - const mergedCalendar = calendarsData.mergedCalendars.find((calendar) => calendar.id === calendarId); - - if (!mergedCalendar) { - throw new Error(`Merged calendar with ID ${calendarId} not found`); - } + const calendarData = JSON.parse(fs.readFileSync(calendarFile, 'utf8')); // Fetch calendar data for each merged calendar - const promises = mergedCalendar.calendars.map((calendar) => { + const promises = calendarData.calendars.map((calendar) => { return axios.get(calendar.url) .then((response) => { return {