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

This commit is contained in:
Shahed Nasser
2024-05-28 10:24:40 +03:00
committed by GitHub
parent 9d3c7829bc
commit 223b3978b2

View File

@@ -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 = {