How to make a call to my own server

Avi4
Tourist
5 0 1

Hi,

I have generated a nodejs app using the cli for the first time.

The app need to send a request to my nodejs server to save something in the database.

So, from the react, I want to fire a request to the server.

 

await fetch('/product',{method: 'get' });

 

In the server I added this:

 

  router.get("/product", async (ctx) => {
    console.log(ctx);
    return {}
});

 

 
I am getting the following error:
 

 

┃   TypeError: Cannot read property 'map' of undefined
┃       at new AuthScopes (/usr/local/src/products-importer/node_modules/@shopify/shopify-api/dist/auth/scopes/index.js:14:35)
┃       at AuthScopes.equals (/usr/local/src/products-importer/node_modules/@shopify/shopify-api/dist/auth/scopes/index.js:38:21)
┃       at /usr/local/src/products-importer/node_modules/@shopify/koa-shopify-auth/dist/src/verify-request/verify-token.js:23:79
┃       at step (/usr/local/src/products-importer/node_modules/tslib/tslib.js:133:27)
┃       at Object.next (/usr/local/src/products-importer/node_modules/tslib/tslib.js:114:57)
┃       at fulfilled (/usr/local/src/products-importer/node_modules/tslib/tslib.js:104:62)
┃       at runMicrotasks (<anonymous>)
┃       at processTicksAndRejections (internal/process/task_queues.js:93:5)​

 

 

What is the correct and secured way to make a request from the client to my server?

Thanks

 

0 Likes
L_J_K
Shopify Staff
Shopify Staff
143 15 24

Hey @Avi4 

Just checking that your Node JS app had followed the Oauth process detailed here? Public apps and custom apps must authenticate using the Oauth 2.0 specification in order to use Shopify's API Resources.

The error you have - Cannot read property 'map' of undefined at new AuthScopes (/node_modules/@shopify/shopify-api/dist/auth/scopes/index.js:14:35 -  looks very similar to an AuthScope error that I've seen, that has been thrown in the Node CLI in the past, so just wanted to check with you to see at what particular point this error was thrown - is it after you have followed the Oauth process? Please let me know when you get a second - thanks!

 

| API Support @ Shopify |
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution!
0 Likes
Avi4
Tourist
5 0 1

I have generated a new app and now this error has disappeared. 

Thanks