Development discussions around Shopify APIs
I'm getting an issue with koa shoipify webhooks where I receive the same APP_UNINSTALL webhook multiple times.
My understanding of the issue is that I should be returning a 200 response code to let Shopify know I have received the call, however I can't see how this is done via the documentation on NPM. For reference my code is:
receiveWebhook({ path: '/webhooks/uninstall', secret: [SHOPIFY_API_SECRET_KEY], // called when a valid webhook is received async onReceived(ctx) { console.log('received webhook: ', ctx.state.webhook.topic); try { // REMOVE STORE DATA HERE } catch (e) { console.log('an error occured deleting a store') } console.log('completed uninstall') return }, }), );
I have tried adding "ctx.res.statusCode = 200;" "ctx.res.status = 200;" "ctx.status = 200;" "return true" and all variations in between.
I am receiving the hook as I see all console logs through the handler.
Any help would be greatly appreciated.
Hi @reecewilliams ,
I believe for Koa the syntax is "ctx.response" not "ctx.res". You should be able to respond to webhook notifications in Koa with a 200 response by setting `ctx.response.status=200` or setting `ctx.response.body = {any non null value}. If response.status has not been set, but response.body is not null, then Koa will automatically set the status to 200 or 204. As well, you can also try `ctx.throw(200)` to automatically respond with a 200, or any other error code you want.
Helpful documents about Koa can be found here: https://github.com/koajs/koa/blob/master/docs/api/response.md and https://devhints.io/koa
Hassain | Developer Support Specialist @ Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Click Accept as Solution
Thanks for getting back to me @hassain
I'm still getting the issue with
ctx.response.body = 'successful'
ctx.response.status = 200
throw(200)
same issue. halp!
User | RANK |
---|---|
10 | |
4 | |
3 | |
3 | |
3 |
As a business owner, have you ever wondered when your customer's first impression of yo...
By Skye Jun 6, 2023We're excited to announce improvements to the threaded messaging experience in our communi...
By TyW May 31, 2023Thank you to everyone who participated in our AMA with Klaviyo. It was great to see so man...
By Jacqui May 30, 2023