fetch calendar data for each merged calendar

This commit is contained in:
Ryan Mwangi 2024-10-24 15:25:02 +03:00
parent c898cb0b24
commit 35deb877a3

View file

@ -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;
});
});
}
}
}