forked from ryanmwangi/CalMerger
fetch calendar data for each merged calendar
This commit is contained in:
parent
c898cb0b24
commit
35deb877a3
1 changed files with 16 additions and 0 deletions
16
server.js
16
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;
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue