Topics covering webhook creation & management, event handling, Pub/Sub, and Eventbridge, in Shopify apps.
Hi There,
New to node and express. I am trying to subscribe a webhook using API with our application upon installing the app. I have followed the documentation on creating an app with Node and express (https://help.shopify.com/en/api/tutorials/build-a-shopify-app-with-node-and-express) and that all works fine. When i try to change the code to POST and subscribe a webhook (instead of the GET shop data in the instructions), I then run into trouble. I have posted the error below and the full code. Hoping someone can help me out here as I feel I am missing something simple.
Unhandled rejection RangeError [ERR_HTTP_INVALID_STATUS_CODE]: Invalid status code: undefined
at ServerResponse.writeHead (_http_server.js:209:11)
at ServerResponse._implicitHeader (_http_server.js:200:8)
at ServerResponse.end (_http_outgoing.js:705:10)
at ServerResponse.send (C:\Users\Scott's PC\Desktop\Tapn\tapn-app-installer\node_modules\express\lib\response.js:221:10)
at request.post.then.catch (C:\Users\Scott's PC\Desktop\Tapn\tapn-app-installer\index.js:109:32)
at tryCatcher (C:\Users\Scott's PC\Desktop\Tapn\tapn-app-installer\node_modules\bluebird\js\release\util.js:16:23)
at Promise._settlePromiseFromHandler (C:\Users\Scott's PC\Desktop\Tapn\tapn-app-installer\node_modules\bluebird\js\release\promise.js:517:31)
at Promise._settlePromise (C:\Users\Scott's PC\Desktop\Tapn\tapn-app-installer\node_modules\bluebird\js\release\promise.js:574:18)
at Promise._settlePromise0 (C:\Users\Scott's PC\Desktop\Tapn\tapn-app-installer\node_modules\bluebird\js\release\promise.js:619:10)
at Promise._settlePromises (C:\Users\Scott's PC\Desktop\Tapn\tapn-app-installer\node_modules\bluebird\js\release\promise.js:695:18)
at _drainQueueStep (C:\Users\Scott's PC\Desktop\Tapn\tapn-app-installer\node_modules\bluebird\js\release\async.js:138:12)
at _drainQueue (C:\Users\Scott's PC\Desktop\Tapn\tapn-app-installer\node_modules\bluebird\js\release\async.js:131:9)
at Async._drainQueues (C:\Users\Scott's PC\Desktop\Tapn\tapn-app-installer\node_modules\bluebird\js\release\async.js:147:5)
at Immediate.Async.drainQueues [as _onImmediate] (C:\Users\Scott's PC\Desktop\Tapn\tapn-app-installer\node_modules\bluebird\js\release\async.js:17:14)
at runCallback (timers.js:705:18)
at tryOnImmediate (timers.js:676:5)
at processImmediate (timers.js:658:5)
Full code:
Solved! Go to the solution
This is an accepted solution.
Hi Evita,
I tried loading the dependencies and adjusting the code but was still unable to get it working. I managed to use axios and followed the instructions in their documentation and got this working (https://www.npmjs.com/package/axios).
Thanks for you help.
Hi, @marsh4 ,
This is Evita from On The Map.
Make sure you install this dependencie - @shopify/koa-shopify-webhooks
Read more here - https://developers.shopify.com/tutorials/build-a-shopify-app-with-node-and-react/listen-for-store-ev...
Best,
Evita
This is an accepted solution.
Hi Evita,
I tried loading the dependencies and adjusting the code but was still unable to get it working. I managed to use axios and followed the instructions in their documentation and got this working (https://www.npmjs.com/package/axios).
Thanks for you help.