我使用Shopify Storefront API和Axios在本地开发电子商店。
Shopify在我使用axios()
时给出回复,但在403 Forbidden
执行相同操作时返回axios.post()
。
这两者之间的区别是什么?
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 }`
})
答案 0 :(得分:0)
axios.post
的声明是axios.post(url[, data[, config]])
。正确的使用方法是:
axios.post(
SHOPIFY_DOMAIN,
`{ shop }`,
{
headers: {
"Content-Type": "application/graphql",
"X-Shopify-Storefront-Access-Token": SHOPIFY_TOKEN
}
}
);
另请参阅:axios API