Get webhook body using Koa

Solved
davydovct
Shopify Partner
18 0 2

Hello,

I'm using Koa-shopify-webhook to register and recieve webhook. I did:

const customersWebhookRegistration = await registerWebhook({
address: `${HOST}/webhooks/customers/create`,
topic: 'CUSTOMERS_CREATE',
accessToken,
shop,
});

if (customersWebhookRegistration.success) {
console.log('Successfully registered customers webhook!');
} else {
console.log('Failed to register customers webhook', customersWebhookRegistration.result);
} 
const webhook = receiveWebhook({ secret: SHOPIFY_API_SECRET_KEY });

router.post('/webhooks/customers/create', webhook, (ctx) => {
console.log('received webhook: ', ctx.state.webhook);
But how can i get response body, such as customers name and etc?
Accepted Solution (1)
pixelperfectweb
Visitor
1 1 0

This is an accepted solution.

hey @davydovct,

webhook content you can find in

ctx.request.body

View solution in original post

Replies 2 (2)
davydovct
Shopify Partner
18 0 2

Okay, i've tried to ouput ctx.response

 

  status: 202,

  message: 'Accepted',

  header: [Object: null prototype] {},

  body: undefined

 

But body is undefined here. Why?

pixelperfectweb
Visitor
1 1 0

This is an accepted solution.

hey @davydovct,

webhook content you can find in

ctx.request.body