So I am trying to access my shopify store using the shopify admin API in node.js.
Here is how I have initialized the api
const { shopifyApi,ApiVersion } = require('@shopify/shopify-api');
require('@shopify/shopify-api/adapters/node');
const shopify = shopifyApi({
apiKey: 'XXXX',
apiSecretKey:'XXXX',
scopes: ['read_products'],
hostName: 'localhost:3000',
shop:'XXX.myshopify.com',
apiVersion: ApiVersion.July22,
});
app.get('/auth', async (req, res) => {
try{
await shopify.auth.begin({
shop: shopify.utils.sanitizeShop(req.query.shop, true),
callbackPath: '/auth/callback',
isOnline: false,
rawRequest: req,
rawResponse: res,
});}
catch(e){
console.log(e)
}
});
But I am getting the following error
InvalidShopError: Received invalid shop argument at Object.sanitizeShop [email removed]
at XXXX\index.js:37:29
at Layer.handle [as handle_request] (XXXX\node_modules\express\lib\router\layer.js:95:5)
at next (XXXX\node_modules\express\lib\router\route.js:144:13)
\index.js:346:12)
at next (XXXX\node_modules\express\lib\router\index.js:280:10)
at expressInit (XXXX\node_modules\express\lib\middleware\init.js:40:5)
What am I doing wrong?