Hello,
Sorry for the rather basic question. I’m new to GraphQL and the Storefront API. I’m trying to expose some metafields. If i’m reading the docs correctly, I need to first expose them (one time) to then be able to request. I’m having no trouble with basic storefront requests.
Below is what my request looks like. Any thoughts on why this isn’t working?
Very much appreciated and again sorry for such a basic question.
best
Eric
function apiSetup () {
return fetch('https://apbookserlin.myshopify.com/admin/api/2021-04/graphql.json', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-Shopify-Access-Token': {ADMIN_API_KEY}
},
body: JSON.stringify({
query: `
mutation($input: MetafieldStorefrontVisibilityInput!) {
metafieldStorefrontVisibilityCreate(
input: $input
) {
metafieldStorefrontVisibility {
id
}
userErrors {
field
message
}
}
}
`,
variables: {
"input": {
"namespace": "event",
"key": "time",
"ownerType": "ARTICLE"
}
},
}),
}).then(response => response.json());
}
apiSetup().then(response => {
console.log(response);
});