Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

270
Vistas
Trouble Accessing Shopify Products using shopify-api-node

I'm attempting to access products in my private Shopify app using the shopify-api-node module but I'm getting a 403 error.

Here's the code I've written with the help of another Stackoverflow post:

const express = require('express');
const path = require('path');
const Shopify = require('shopify-api-node');
const https = require('https');
const fetch = require('node-fetch');

const {request, gql, GraphQLClient} = require('graphql-request');

const app = express();
const port = 3000;



const apikey = "*";
const apipassword = "*";
const endpoint = "https://<store>.myshopify.com/admin/api/2021-07/graphql.json"


const shopify = new Shopify({
    shopName: '<store>.myshopify.com',
    apiKey: '*',
    password: '*',
    autoLimit: true
});

app.set('view-engine', 'ejs');
app.use(express.static(path.join(__dirname, 'public')));


app.get('/', function(req, res) {
    res.render(path.join(__dirname, '/views/index.ejs'));
    shopify.product.count()
    .then(async (count) => {
        if (count > 0) {

            const pages = Math.ceil(count / 250);
            let products = [];

            for (i = 0; i < pages; i++) {
                // use Promise.all instead of waiting for each response
                const result = await shopify.product.list({
                    limit: 250,
                    page: i + 1,
                    fields: 'id, variants'
                });
                products = products.concat(result);
            }
            // products array should have all the products. Includes id and variants
            console.log(products);
        }
    })
    .catch(err => {
        console.log(err);
    });
})

app.get('/treasures', function(req, res) {
    res.render(path.join(__dirname, '/views/treasure.ejs'));
});

app.get('/poetry_books', (req, res) => {

    res.send('Hello World');
});

app.listen(port);

If anyone could tell me what I'm doing wrong or suggest a better approach that would be amazing.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

I don't think you can use the page parameter anymore. Try something like that instead:

let last_id = 0;
do {
    const results = await ShopifyAPI.product.list({
      limit: 250,
      since_id: last_id,
    });

    // Do something with your product data

    last_id = (results.length === 250 ? results[results.length - 1].id : 0);
} while (last_id);
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda