forked from ryanmwangi/CalMerger
update saveCalendarData function
This commit is contained in:
parent
026367fb17
commit
69a6718af8
1 changed files with 9 additions and 2 deletions
11
server.js
11
server.js
|
@ -114,10 +114,17 @@ app.get('/calendar/:id', (req, res) => {
|
||||||
});
|
});
|
||||||
|
|
||||||
//function to save CalendarData to calendars.json
|
//function to save CalendarData to calendars.json
|
||||||
function saveCalendarData(calendarId, calendars) {
|
function saveCalendarData(calendarId, linkGroupName, calendars) {
|
||||||
let calendarsData = { mergedCalendars: [] };
|
let calendarsData = { mergedCalendars: [] };
|
||||||
if (fs.existsSync(CALENDARS_FILE)) {
|
if (fs.existsSync(CALENDARS_FILE)) {
|
||||||
calendarsData = JSON.parse(fs.readFileSync(CALENDARS_FILE, 'utf8'));
|
try {
|
||||||
|
const fileContent = fs.readFileSync(CALENDARS_FILE, 'utf8');
|
||||||
|
if (fileContent) {
|
||||||
|
calendarsData = JSON.parse(fileContent);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error reading calendars file:', error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
calendarsData.mergedCalendars.push({
|
calendarsData.mergedCalendars.push({
|
||||||
id: calendarId,
|
id: calendarId,
|
||||||
|
|
Loading…
Add table
Reference in a new issue