I'm using Shopify Storefront API and Axios to develop locally a e-shop.
Shopify give me a response when I use axios()
, but it returns 403 Forbidden
when I do the same thing with axios.post()
.
What's the difference between those two?
axios.post(
SHOPIFY_DOMAIN,
{
headers: {
"Content-Type": "application/graphql",
"X-Shopify-Storefront-Access-Token": SHOPIFY_TOKEN
},
data: `{ shop }`
})
axios({
method: "post",
url: SHOPIFY_DOMAIN,
headers: {
"Content-Type": "application/graphql",
"X-Shopify-Storefront-Access-Token": SHOPIFY_TOKEN
},
data: `{ shop }`
})
The declaration of axios.post
is axios.post(url[, data[, config]])
. The correct way of using is:
axios.post(
SHOPIFY_DOMAIN,
`{ shop }`,
{
headers: {
"Content-Type": "application/graphql",
"X-Shopify-Storefront-Access-Token": SHOPIFY_TOKEN
}
}
);
See also: axios API
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With