Dedicated to the Hydrogen framework, headless commerce, and building custom storefronts using the Storefront API.
Is it possible to fetch data from the frontend without using JS-Buy-SDK?
I'm getting cors issues when doing it like this:
const query = `
{
products(first: 10) {
edges {
cursor
node {
id
}
}
}
}
`;
const URL = `https://${storeDomain}/api/2022-04/graphql.json`;
const options = {
endpoint: URL,
method: "POST",
headers: {
"X-Shopify-Storefront-Access-Token": accessToken,
"Content-Type": "application/json",
},
body: JSON.stringify({ query })
}
fetch(URL, options).then((response) => response.json());
Try adding "Accept: application/json"