Skip to content

Commit

Permalink
Adding an example to cron hook (directus#6188)
Browse files Browse the repository at this point in the history
* Adding an example to cron hook

* Update docs/guides/api-hooks.md

Co-authored-by: Rijk van Zanten <rijkvanzanten@me.com>
  • Loading branch information
juancarlosjr97 and rijkvanzanten authored Jun 10, 2021
1 parent 4cb8d1f commit 5826fd6
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion docs/guides/api-hooks.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,17 @@ module.exports = function registerHook({ exceptions }) {

Hooks support running on an interval through [`node-cron`](https://www.npmjs.com/package/node-cron). To set this up,
provide a cron statement in the event scope as follows: `cron(<statement>)`, for example `cron(15 14 1 * *)` (at 14:15
on day-of-month 1) or `cron(5 4 * * sun)` (at 04:05 on Sunday).
on day-of-month 1) or `cron(5 4 * * sun)` (at 04:05 on Sunday). See example below:

```js
module.exports = function registerHook() {
return {
'cron(*/15 * * * *)': async function () {
await axios.post('http://example.com/webhook', { message: "Another 15 minutes passed..." });
},
};
};
```

## 3. Register your Hook

Expand Down

0 comments on commit 5826fd6

Please sign in to comment.