docs: fix data payload of events in subscribers (#7406)

This commit is contained in:
Shahed Nasser authored and GitHub committed 2024-05-28 09:24:40 +02:00
1 parent 9d3c7829bc
commit 223b3978b2
1 file changed
+4 -2
@@ -16,7 +16,8 @@ For example:
export const highlights = [
["7", "", "The event's data payload."],
["8", "{ id: string }", "The type of expected data payloads."]
["8", "{ id: string }", "The type of expected data payloads."],
["9", '"data" in data ? data.data.id : data.id', "The payload data is either in `data.data` or directly in `data`."]
]
```ts title="src/subscribers/product-created.ts" highlights={highlights}
@@ -28,7 +29,8 @@ import {
export default async function productCreateHandler({
data,
}: SubscriberArgs<{ id: string }>) {
console.log(`The product ${data.id} was created`)
const productId = "data" in data ? data.data.id : data.id
console.log(`The product ${productId} was created`)
}
export const config: SubscriberConfig = {