diff --git a/docs/.vitepress/config.ts b/docs/.vitepress/config.ts index 8bf3e58..3d517e7 100644 --- a/docs/.vitepress/config.ts +++ b/docs/.vitepress/config.ts @@ -71,6 +71,7 @@ export default defineConfig({ { text: 'Base', link: '/base' }, { text: 'Run on init', link: '/with-params' }, { text: 'Custom time', link: '/custom-time' }, + { text: 'Async', link: '/async' }, ], }, { diff --git a/docs/examples/async.md b/docs/examples/async.md new file mode 100644 index 0000000..ad4c015 --- /dev/null +++ b/docs/examples/async.md @@ -0,0 +1,16 @@ +# Async + +`defineCronHandler` supports async functions. + +```ts +// server/cron/job.ts +import { defineCronHandler } from '#nuxt/cron' + +export default defineCronHandler('houdrly', async () => { + const data = $fetch('https://jsonplaceholder.typicode.com/todos/1') + + console.log(data) +}) +``` + +A list of all prepared times can be found in [Presets](../api/presets)