401 Error while trying to fetch customers through REST API

Highlighted
New Member
5 0 0

Hi,

I'm building ecommerce in Gatsby and trying to fetch all customers through REST API. Url I use is 

https://${shop_name}.myshopify.com/admin/api/2020-07/customers.json

When I try to make request in Postman everything works with X-Shopify-Access-Token declared, but when I try the same, even with 'no-cors' I got ERR-ABORTED 401.

That's how my request look like:

await fetch(
`https://{shop_name}.myshopify.com/admin/api/2020-07/customers.json`,
{
method: 'GET',
mode: 'no-cors',
'X-Shopify-Access-Token': 'access_token',
}
)
.then((res) => console.log(res))
.catch((err) => console.log(err))

 Does anyone know where I made mistake?

0 Likes