I’m trying to get some basic information about my site through the Shopify Storefront API. I’ve made a private app, and tested the process of making requests with GraphiQL as well as curl and it returns the data I need and works fine. But when I try to make requests in my project, it gives me a 403 error. I’m trying to make the request inside a Node Express app. Here’s the code:
const express = require('express')
const router = express.Router()
const axios = require('axios')
router.post('/get-info', (req, res, next) => {
axios({
url: 'https://my-site.myshopify.com/api/2019-07/graphql.json',
method: 'post',
data: {
query: `
{
shop {
name
primaryDomain {
url
host
}
}
}
`
},
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
'X-Shopify-Access-Token': 'my-access-token'
},
}).then((result) => {
console.log(result.data)
}).catch(error => {
console.log(error)
})
})
Any ideas why this would be happening?