Storefront API - custom cart

Storefront API - custom cart

NikosKalfas
Visitor
1 0 0

Hello,

 

I am very new to all this so apologies beforehand if my question is silly.

 

I am following this guide https://www.youtube.com/watch?v=FJOJmKFngLI&t=1458s trying to build a Gatsby test e-shop one step at a time. 

 

The issue I am having is, on the video, they're using netlify functions to make the queries and then they're fetching from those files from the components.

 

I can't do that as I am not using netlify functions or even node back end. Do I have to use something like for that or is there way to do it from the components.

 

This is part of my code, where I have a util's file create-cart.ts which fetches the api.

create-cart.jpg

 

Now, in the video they're fetching from that file using the netlify functions for routing (please do correct me if I'm wrong), but I managed to get the desired result of the video's part by just calling the function as shown in the image below:

 

Cart.jpg

 

Now my problem is this file, where I need to the cart, gets some query parameters, which I can't find any other way to pass other than an actual fetch?

load-cart.jpg

 

When I try to do something similar with before like so: 

cart 2.jpg

 

I then get this error : 

 

error.jpg

 

Again I really apologise for the very long post but I'm not sure where else to ask.

Any help would be really appreciated!

 

Thanks,

Nikos

Replies 0 (0)