use POST method in refresh button event listener

This commit is contained in:
Ryan Mwangi 2024-10-22 14:56:57 +03:00
parent c6117e3470
commit a6b3747bfe
1 changed files with 4 additions and 1 deletions

View File

@ -80,8 +80,11 @@ function isValidUrl(url) {
// Refresh button event listener // Refresh button event listener
refreshCalendarsButton.addEventListener('click', () => { refreshCalendarsButton.addEventListener('click', () => {
if (mergedUrl) { if (mergedUrl) {
// Extract the calendar ID from the URL
const calendarId = mergedUrl.split('/').pop();
// Call the server to refresh the merged calendar // Call the server to refresh the merged calendar
fetch(`/refresh/${mergedUrl.split('/').pop()}`) // Extract the calendar ID from the URL fetch(`/refresh/${calendarId}`, { method: 'POST' })
.then((response) => { .then((response) => {
if (!response.ok) { if (!response.ok) {
throw new Error('Failed to refresh calendar data'); throw new Error('Failed to refresh calendar data');