Fetch command causes 401 status code

Highlighted
Tourist
4 0 1

Hi, I tried to use fetch command in my react app, but got 401 status code.

In Postman all works perfect.

 

fetch("https://my_shop.myshopify.com/admin/api/2019-10/products/my_product_id/images.json", {
mode: 'no-cors',
method: 'GET',
headers: {
"X-Shopify-Access-Token": "my_private_app_password",
"Content-type": "application/json"
}
});

 

 

1 Like
Shopify Partner
50 10 21

Hey Levaif,

The "no-cors" flag will prevent your X-Shopify-Access-Token header from being sent, which results in the request being denied.

However, even if you used the appropriate setting, Shopify's CORS policy would prohibit making this request.

Have a look at this thread for some guidance on how to proceed:
https://community.shopify.com/c/Shopify-APIs-SDKs/Using-APIs-from-a-different-origin-domain/td-p/502...

Hope that helps!

Code 402 Inc - Ecommerce Consulting in Kitchener, Ontario, Canada
0 Likes