Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Product Page Session Error #3

Closed
ChristopherCapito opened this issue Apr 18, 2022 · 1 comment
Closed

Product Page Session Error #3

ChristopherCapito opened this issue Apr 18, 2022 · 1 comment

Comments

@ChristopherCapito
Copy link

ChristopherCapito commented Apr 18, 2022

Greetings,

I am currently modifying this on a fork. I got an error when trying to access your sample page.

nextjs-shopify-app-base-nextjs-1 | error - (api)/pages/api/products.js (10:53) @ WEBPACK_DEFAULT_EXPORT
TypeError: Cannot read properties of undefined (reading 'shop')
nextjs-shopify-app-base-nextjs-1 | 8 |
nextjs-shopify-app-base-nextjs-1 | 9 | const session = await Shopify.Utils.loadCurrentSession(req, res, true);
nextjs-shopify-app-base-nextjs-1 | > 10 | const client = new Shopify.Clients.Graphql(session.shop, session.accessToken);
nextjs-shopify-app-base-nextjs-1 | | ^
nextjs-shopify-app-base-nextjs-1 | 11 | // Use client.get to request the specified Shopify GraphQL API endpoint, in this case products.
nextjs-shopify-app-base-nextjs-1 | 12 | const products = await client.query({
nextjs-shopify-app-base-nextjs-1 | 13 | data: `{
nextjs-shopify-app-base-nextjs-1 | wait - compiling /_error (client and server)...

Redis is working correctly (seemingly), and it says there is one key in the database after installation.

nextjs-shopify-app-base-nextjs-1 | token record from redis: {
nextjs-shopify-app-base-nextjs-1 | id: 'offline_REDACTED-development.myshopify.com',
nextjs-shopify-app-base-nextjs-1 | shop: 'REDACTED-development.myshopify.com',
nextjs-shopify-app-base-nextjs-1 | state: '628137656797721',
nextjs-shopify-app-base-nextjs-1 | isOnline: false,
nextjs-shopify-app-base-nextjs-1 | accessToken: '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',
nextjs-shopify-app-base-nextjs-1 | scope: 'write_products,write_customers,write_draft_orders,write_files'
nextjs-shopify-app-base-nextjs-1 | }

Do you have any idea what could be the problem? I changed the Redis loglevel to "Debug" and it does affirm one key in the database. I used the CLI to retrieve it and it looks okay ( i guess)

I am both new to Shopify aswell as Redis. My other sample app just used the InMemory storage, but since your project depends on having Redis, I am bumping into this issue. If you have any idea what could be the issue here I would be very thankful

@ChristopherCapito
Copy link
Author

Update: CASE CLOSED :D I just had to add the "false" boolean for "isOnline" in the Session provider. Now it retrieves the products and the page works fine.

I will need to read up on the Shopify.utils.loadCurrentSession and what "isOnline" means here.

Thanks for the baseplate! Once I am done cleaning up my fork, I will create a PR if you want.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant