We're moving the community! Starting July 7, the current community will be read-only for approx. 2 weeks. You can browse content, but posting will be temporarily unavailable. Learn more

Struggling to fetch products.json from API, can anyone help?

Struggling to fetch products.json from API, can anyone help?

Pablo213
Shopify Partner
10 0 1

Hi, is there anybody who can helps me with the fetch request to shopify API? I would like to get all products and use them for product select in form. I dont really know whats wrong with it.

I read docs and i think it should work this way, but i am getting console errors and cant get response.

I had created private app because access and tokens, but still cant find the solution.

 

Výstřižek2.PNG

Výstřižek.PNG
 

 

Replies 5 (5)
Pablo213
Shopify Partner
10 0 1

Do you mean add this code to headers: {

'Content-Type': 'application/json',
'X-Shopify-Access-Token':"fb70610e4eb8cbd8c14557560e8a190a-1681990272", 'Access-Control-Allow-Origin': '*',

}

this way? Thats what i found on the internet

Pablo213
Shopify Partner
10 0 1

I have it this way now, but still doesnt work

Pablo213_0-1681991470510.png

 

Pablo213
Shopify Partner
10 0 1

Idk man, but i am doing it with javascript now and still doesnt work..

Pablo213
Shopify Partner
10 0 1

I use it that way exactly, but where is the problem? In headers i have an extra access- token which i should use i guess?

Pablo213_0-1681993019224.png

 

Pablo213
Shopify Partner
10 0 1

Am i doing anything wrong besides writing differently?