aboutsummaryrefslogtreecommitdiffstats
path: root/core/src/ajax-cron.ts
blob: d903a3596eaf72db7cb7aed329609eaa3c1a2156 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
/**
 * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
 * SPDX-License-Identifier: AGPL-3.0-or-later
 */

import { getRootUrl } from '@nextcloud/router'
import logger from './logger'

window.addEventListener('DOMContentLoaded', async () => {
	// When the page is loaded send GET to the cron endpoint to trigger background jobs
	try {
		logger.debug('Running web cron')
		await window.fetch(`${getRootUrl()}/cron.php`)
		logger.debug('Web cron successfull')
	} catch (e) {
		logger.debug('Running web cron failed', { error: e })
	}
})