From 35deb877a33a56f682b37722a5dcc80bc5e39bac Mon Sep 17 00:00:00 2001 From: Ryan Mwangi Date: Thu, 24 Oct 2024 15:25:02 +0300 Subject: [PATCH] fetch calendar data for each merged calendar --- server.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/server.js b/server.js index baabff5..5aa142a 100644 --- a/server.js +++ b/server.js @@ -125,6 +125,22 @@ app.get('/calendar/:name', async (req, res) => { // Read the JSON file to get the source URL and other details const jsonData = JSON.parse(fs.readFileSync(jsonFilePath, 'utf8')); const { linkGroupName, calendars } = jsonData; + + // Fetch calendar data for each merged calendar + const promises = calendars.map((calendar) => { + return axios.get(calendar.url) + .then((response) => { + return { + data: response.data, + prefix: calendar.prefix, + override: calendar.override, + }; + }) + .catch((error) => { + console.error(error); + return null; + }); + }); } } }