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?
Hey Community! As we jump into 2025, we want to give a big shout-out to all of you wh...
By JasonH Jan 7, 2025Hey Community! As the holiday season unfolds, we want to extend heartfelt thanks to a...
By JasonH Dec 6, 2024Dropshipping, a high-growth, $226 billion-dollar industry, remains a highly dynamic bus...
By JasonH Nov 27, 2024