Resolve API END POINT Shopify sveltekit
Budget: $10 – $30 USD
I'm trying to get access to my shopify api from sveltekit, so I used an .env
VITE_SHOPIFY_STOREFRONT_API_TOKEN = ""
VITE_SHOPIFY_API_ENDPOINT = ""
Which allows me to configure the whole
Then i use this :
export const postToShopify = async ({ query, variables }) => {
try {
// @ts-ignore
const result = await fetch(import.meta.env.VITE_SHOPIFY_API_ENDPOINT, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-Shopify-Storefront-Access-Token': import.meta.env.VITE_SHOPIFY_STOREFRONT_API_TOKEN
},
body: JSON.stringify({ query, variables })
}).then((res) => res.json());
if (result.errors) {
console.log({ errors: result.errors });
} else if (!result || !result.data) {
console.log({ result });
return 'No results found.';
}
return result.data;
} catch (error) {
console.log(error);
}
};
But i don't know to to put in : "VITE_SHOPIFY_API_ENDPOINT = """
If someone can help me, thank you
VITE_SHOPIFY_STOREFRONT_API_TOKEN = ""
VITE_SHOPIFY_API_ENDPOINT = ""
Which allows me to configure the whole
Then i use this :
export const postToShopify = async ({ query, variables }) => {
try {
// @ts-ignore
const result = await fetch(import.meta.env.VITE_SHOPIFY_API_ENDPOINT, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-Shopify-Storefront-Access-Token': import.meta.env.VITE_SHOPIFY_STOREFRONT_API_TOKEN
},
body: JSON.stringify({ query, variables })
}).then((res) => res.json());
if (result.errors) {
console.log({ errors: result.errors });
} else if (!result || !result.data) {
console.log({ result });
return 'No results found.';
}
return result.data;
} catch (error) {
console.log(error);
}
};
But i don't know to to put in : "VITE_SHOPIFY_API_ENDPOINT = """
If someone can help me, thank you