on GitHub" data-tooltip-id=":Rblcldtb:">v2.6·
In this chapter, you'll learn how subscribers receive an event's data payload.
When events are emitted, they’re emitted with a data payload.
The object that the subscriber function receives as a parameter has an event
property, which is an object holding the event payload in a data
property with additional context.
For example:
4} from "@medusajs/framework"5 6export default async function productCreateHandler({7 event,8}: SubscriberArgs<{ id: string }>) {9 const productId = event.data.id10 console.log(`The product ${productId} was created`)11}12 13export const config: SubscriberConfig = {14 event: "product.created",15}
The event
object has the following properties:
data
objectname
stringmetadata
objectOptionalThis logs the product ID received in the product.created
event’s data payload to the console.