From 403e8f7bb904a02b574fb4df46dae7099d11b1a8 Mon Sep 17 00:00:00 2001 From: hywax Date: Sat, 23 Mar 2024 01:36:51 +0500 Subject: [PATCH] docs: async example --- docs/.vitepress/config.ts | 1 + docs/examples/async.md | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 docs/examples/async.md 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)