Files
triggerdotdev--trigger.dev/docs/_snippets/random-example.mdx
T
nicktrn cf8f994604 Feature: io.random() (#716)
* Add io.random

* Add changeset

---------

Co-authored-by: Eric Allam <eric@trigger.dev>
2023-11-03 11:07:12 +00:00

22 lines
478 B
Plaintext

```typescript Random example
client.defineJob({
id: "random-job",
name: "Random Job",
version: "0.0.1",
trigger: eventTrigger({
name: "example.event",
}),
run: async (payload, io, ctx) => {
// generate random numbers
const small = await io.random("random-small");
const large = await io.random("random-large", {
min: 10,
max: 200,
round: true
});
await io.logger.info(`${small} is smaller than ${large}`);
},
});
```