I am working on a project using the ShopifyStorefrontApi as well as the shopify-buy npm package.
Netlify functions work flawlessly on the localhost, but once everything is deployed I am getting a reference error that fetch is not defined. When the create-cart function gets executed, which is on first page load, I store the data in localStorage. But instead i can see what error it returns in the localStorage:
{"errorType":"ReferenceError","errorMessage":"fetch is not defined","trace":["ReferenceError: fetch is not defined","
at Client3.fetcher (/var/task/netlify/functions/create-cart.js:1163:9)"," at Client3.send (/var/task/netlify/functions/create-cart.js:1260:23)","
at CheckoutResource2.create (/var/task/netlify/functions/create-cart.js:7897:37)"," at Runtime.handler (/var/task/netlify/functions/create-cart.js:8899:45)","
at Runtime.handleOnceNonStreaming (file:///var/runtime/index.mjs:1089:29)"]}
I think that it might have to do something with the node version, once I updated to node18 everything broke big time. Then I managed to revert to node16 and refactor the api calls using axios instead of fetch. Been struggling on this for many hours, help would be appreciated.
The node version I am on is 16.19.0, @types/node is = to the node version.
NODE_VERSION env is set to 16.19.0 in the netlify ui.
I will attach images of the shopify client and of the way i am making the api calls.
I can give some more context about the 3th screenshot if needed.
(restricted to upload only one image so I will do it this way)