docs: fix data payload of events in subscribers (#7406)
This commit is contained in:
@@ -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 = {
|
||||
|
||||
Reference in New Issue
Block a user