Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: fix data payload of events in subscribers #7406

Merged
merged 1 commit into from
May 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand All @@ -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 = {
Expand Down
Loading