gatsby-woocommerce-themes
gatsby-woocommerce-themes copied to clipboard
When adding product to cart I get: Cannot read property 'message' of undefined
onError src/components/cart/add-to-cart-button/index.js:63.
60 | },
61 | onError: (error) => {
62 | if (error) {
> 63 | setRequestError(error.graphQLErrors[0].message);
Installed latest plugins. Any suggestions on what might be the issue would be greatly appreciated.
I cannot replicate the issue, I deployed and tested here and it works fine. https://gatsby-woocommerce-theme.netlify.app/
Can you console.log( error ) and see what you are getting?
when i console.log(error) I get console.log( error )
VM198:1 Uncaught ReferenceError: error is not defined
at
I should have also mentioned that when I clicked add to cart this mutation error came up. I am using the app Local for my local wp development on my site. .env file WORDPRESS_SITE_URL=http://mikestore.local GATSBY_SITE_URL=http://localhost:8000
and when I go to http://localhost:8000/__graphQL it all works.
It is when I click on add to cart that this happens in console:
Uncaught (in promise) TypeError: Cannot read property 'message' of undefined at onError (index.js:63) at MutationData.../node_modules/@apollo/client/react/data/MutationData.js.MutationData.onMutationError (MutationData.js:90) at MutationData.js:22
onError @ index.js:63 ../node_modules/@apollo/client/react/data/MutationData.js.MutationData.onMutationError @ (anonymous) @ Promise.catch (async) MutationData._this.runMutation @ handleAddToCartClick @ callCallback @ invokeGuardedCallbackDev @ invokeGuardedCallback @ invokeGuardedCallbackAndCatchFirstError @ executeDispatch @ processDispatchQueueItemsInOrder @ processDispatchQueue @ dispatchEventsForPlugins @ (anonymous) @ batchedEventUpdates$1 @ batchedEventUpdates @ dispatchEventForPluginEventSystem @ attemptToDispatchEvent @ dispatchEvent @ unstable_runWithPriority @ runWithPriority$1 @ discreteUpdates$1 @ discreteUpdates @ dispatchDiscreteEvent
I am also experiencing this issue. I have a hunch it's relating to a persisting CORS policy issue. Has there been any movement on this? I haven't been able to come to a resolution. @imranhsayed @catboxer
I was also experiencing this issue. I resolved the error by changing the GATSBY_WORDPRESS_URL env variable to my WordPress backend url
That worked for me. Thanks
getting this error. Please help. have tried everything i can think of