forked from ryanmwangi/CalMerger
Modify the updateMergedCalendar function to update all merged calendars
This commit is contained in:
parent
896738a123
commit
e6b63cd85f
33
server.js
33
server.js
|
@ -167,24 +167,23 @@ async function updateMergedCalendar(){
|
||||||
if (!calendarsData || !calendarsData.linkGroups) {
|
if (!calendarsData || !calendarsData.linkGroups) {
|
||||||
throw new Error('Invalid calendars data structure');
|
throw new Error('Invalid calendars data structure');
|
||||||
}
|
}
|
||||||
console.log(calendarsData);
|
|
||||||
// Fetch calendar data for each link group
|
// Fetch calendar data for each link group
|
||||||
const promises = calendarsData.linkGroups.map((linkGroup) => {
|
for (const mergedCalendar of calendarsData.mergedCalendars) {
|
||||||
return Promise.all(linkGroup.links.map((link) => {
|
const promises = mergedCalendar.calendars.map((calendar) => {
|
||||||
return axios.get(link.url)
|
return axios.get(calendar.url)
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
return {
|
return {
|
||||||
data: response.data,
|
data: response.data,
|
||||||
prefix: link.prefix,
|
prefix: calendar.prefix,
|
||||||
override: link.override,
|
override: calendar.override,
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
}));
|
});
|
||||||
});
|
|
||||||
|
|
||||||
const results = await Promise.all(promises);
|
const results = await Promise.all(promises);
|
||||||
// Filter out any failed requests
|
// Filter out any failed requests
|
||||||
|
|
Loading…
Reference in New Issue