Stuck on final tutorial step

Solved
Highlighted
New Member
4 0 0

Hey!

 

Thank you for reading my message! I'm on the very last step of your Shopify App Dev. Tutorial (https://shopify.dev/tutorials/build-a-shopify-app-with-node-and-react/listen-for-store-events-with-w...) and I cannot complete the last step.

 

Having added the subsequent code, re webhooks, I get the following error in my terminal:

 

[ ready ] compiled successfully
(node:3047) UnhandledPromiseRejectionWarning: ReferenceError: router is not defined
at /Users/Tom/Desktop/popup-proof/server.js:63:3
(node:3047) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:3047) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

I expect to see "received webhook: { topic: 'YOURWEBHOOKTOPIC', domain: 'YOURSHOPIFYSTORE' }"

 

I'm not sure where to turn to complete this tutorial and would like your help.

 

Best wishes,
Tom Perks

0 Likes
Highlighted
Shopify Staff
Shopify Staff
6 1 1

This is an accepted solution.

1 Like
Highlighted
New Member
4 0 0

Almost!

 

I was missing "const router = new Router();" on line 28.

 

Thanks!

0 Likes
Highlighted
Shopify Staff
Shopify Staff
6 1 1

Glad you got it! 🙌

0 Likes
Highlighted
New Member
2 0 1

@theoldbarn Did you manage to fix the second error regarding the catch block? I added the piece of code to instantiate the router as @pauldowman suggested but I am still left with the following error:

(node:9596) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:9596) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Could you please help me fix this last bit?

Thanks!

0 Likes
Highlighted
Tourist
3 0 6

If the router line doesn't fix this, it's because you're using a newer version of koa-router and not the 8.0.8 version that Shopify uses in their tutorial. 

To downgrade koa-router, navigate to your project directory on the command line and run

sudo npm install koa-router@~8.0.8

Hopefully that helps!

2 Likes
Highlighted
New Member
1 0 0

@pauldowman, The missing line that solved the problem isn't included in the tutorial. Perhaps someone from Shopify could update it to include that line, and fix or address the version issue with koa-router @VineshG mentions? 

0 Likes
Highlighted
Shopify Staff
Shopify Staff
6 1 1

Thanks, we will get that fixed.

0 Likes