validate the different calender inputs

This commit is contained in:
Ryan Mwangi 2024-10-02 02:06:52 +03:00
parent e5216b24e1
commit 89bd4582d1
1 changed files with 5 additions and 1 deletions

View File

@ -14,9 +14,13 @@ app.get('/', (req, res) => {
}); });
app.post('/merge', async (req, res) => { app.post('/merge', async (req, res) => {
const { cal1Url, cal1Prefix, cal2Url, cal2Prefix } = req.body; const { calendars } = req.body;
try { try {
//validate the input
if (!calendars || !Array.isArray(calendars)) {
return res.status(400).json({ error: 'Invalid input' });
}
// Fetch calendar data from URLs // Fetch calendar data from URLs
const cal1Data = await axios.get(cal1Url); const cal1Data = await axios.get(cal1Url);
const cal2Data = await axios.get(cal2Url); const cal2Data = await axios.get(cal2Url);