Fetch calendar data from URL

This commit is contained in:
Ryan Mwangi 2024-11-04 13:56:48 +03:00
parent f677014cb1
commit 1631ba3478
1 changed files with 14 additions and 13 deletions

View File

@ -52,7 +52,7 @@ app.post('/merge', async (req, res) => {
// Read calendar data from local file // Read calendar data from local file
const data = fs.readFileSync(path.resolve(calendar.url), 'utf-8'); const data = fs.readFileSync(path.resolve(calendar.url), 'utf-8');
return Promise.resolve({ return Promise.resolve({
url: data, data: data,
prefix: calendar.prefix, prefix: calendar.prefix,
override: calendar.override, override: calendar.override,
}); });
@ -62,18 +62,19 @@ app.post('/merge', async (req, res) => {
return Promise.resolve(null); return Promise.resolve(null);
} }
} else { } else {
return axios.get(calendar.url) // Fetch calendar data from URL
.then((response) => { return axios.get(calendar.url)
return { .then((response) => {
data: response.data, return {
prefix: calendar.prefix, data: response.data,
override: calendar.override, prefix: calendar.prefix,
}; override: calendar.override,
}) };
.catch((error) => { })
console.error(`Error fetching calendar from ${calendar.url}:`, error); .catch((error) => {
return null; console.error(`Error fetching calendar from ${calendar.url}:`, error);
}); return null;
});
} }
}); });