Dedicated to the Hydrogen framework, headless commerce, and building custom storefronts using the Storefront API.
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?
Hi @emily_into_what,
Have you granted access for your private app to make requests to the storefront? From the app setup page in the admin:
Ryan | Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit the Shopify Help Center or the Shopify Blog