All things Shopify and commerce
I am wondering why I get the error
Extensions Unauthorized when I am trying to fetch a simple graphql query. I am fetching from
/api/2024-10/graphql.json.. Please advise.... you should be able to do this fetch from main-products.liquid. My code is below -- ignore the debugging alert messages: I have checked my graphql query ... it ran successfully through graphql....
fetch('/api/2024-10/graphql.json', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-Shopify-Storefront-Access-Token': 'xxxx'
},
body: JSON.stringify({
query: `
{
productVariant(id: "gid://shopify/ProductVariant/123")
{
id
title
}
}
`
})
})
.then(response => response.json())
.then(data => {
// Handle the product data
alert ('in ZZZZZZZZZ product product data....');
alert('HEY ZZZZZ data:' + JSON.stringify(data));
alert ('ZZZZZZZZZZafter product product data');
})
.catch(error => {
// Handle errors
alert ('ZZZZZZZZZin product product error....' + error);
console.error(error);
});
p.s. my token is correct -- I use it elsewhere and it works. I can fetch from products.json why not api/graphql.json?
Learn how to build powerful custom workflows in Shopify Flow with expert guidance from ...
By Jacqui May 7, 2025Did You Know? May is named after Maia, the Roman goddess of growth and flourishing! ...
By JasonH May 2, 2025Discover opportunities to improve SEO with new guidance available from Shopify’s growth...
By Jacqui May 1, 2025