Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

268
Views
Problemas para acceder a los productos de Shopify usando shopify-api-node

Estoy intentando acceder a los productos en mi aplicación privada de Shopify usando el módulo shopify-api-node pero recibo un error 403.

Aquí está el código que he escrito con la ayuda de otra publicación de Stackoverflow:

 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);

Si alguien pudiera decirme qué estoy haciendo mal o sugerir un mejor enfoque, sería increíble.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

No creo que puedas usar más el parámetro de página. Prueba algo así en su lugar:

 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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!