Using the NextJS Store Demo, Product does not (add to Cart)



Anyone solve this? Thank you in advance.


Hi Jeff,

Are you getting any errors back from the API? If you could show me the response from the developer console that would be great.



Uncaught (in promise) ReferenceError: cartId is not defined
at ProxyComponent._callee$ (AddToCart.js:29)
at tryCatch (main.js:12181)
at Generator.invoke [as _invoke] (main.js:12415)
at Generator.prototype.(:3000/anonymous function) [as next] (http://localhost:3000/_next/-/main.js:12233:21)
at step (product.js:30)
at product.js:30
at new Promise ()
at Object.onClick (product.js:30)
at apply (_apply.js:15)
at baseInvoke (_baseInvoke.js:21)


Before the uncaught…I’m also getting:

A bad HTTP response code (404) was received when fetching the script.
Failed to load resource: net::ERR_INVALID_RESPONSE
AddToCart.js:16 props: {productId: “9793227c-d030-454b-b50a-e31ded0c52d4”}
AddToCart.js:17 state: {loading: false, quantity: 1}


Hey Jeff,

The cartId is something that you need to set. Its a unique identifier for the cart. (like cartID = “yourcartID”. It can be something static like that. Looking at the example store it looks like one is being used. Have you taking a look to see if this is being set and used (‘mcart’). Are you able to print out cartId before you try to add products?

const cartId = await localStorage.getItem('mcart')



I made that changes and now I get this:

POST 400 (Bad Request)
product.js:30 Uncaught (in promise) {status: 400, ok: false, json: {…}}
step @ product.js:30
(anonymous) @ product.js:30
Promise.then (async)


It works now…Thank you. I had to increment the inventory from 0 to 10. Thank you!


Hi Jeff1
Thank you :slight_smile:
I have the same error , I wanted to increament the inventory , but it seems the inventory unit option is not available to me in the trial. have you experienced the error during trial?



Go into your product and try an inventory transaction (on the right side of the page). Record a New Transaction. Choose increment…Good Luck to you.


Thank you , sorted ! :slight_smile:


This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.