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

223
Views
SyntaxError: final inesperado de la entrada JSON en JSON.stringify

estoy recibiendo un error

 Looking for new purchases new order appears undefined:1 SyntaxError: Unexpected end of JSON input at JSON.parse (<anonymous>) at Response.json (file:///C:/Users/Admin/Documents/Allegro/server/node_modules/node-fetch/src/body.js:149:15) at processTicksAndRejections (node:internal/process/task_queues:96:5) at async default.request (file:///C:/Users/Admin/Documents/Allegro/server/modules/allegroAPI.js:90:16) at async default.sendPurchasedProducts (file:///C:/Users/Admin/Documents/Allegro/server/modules/allegroAPI.js:166:7) at async Timeout._onTimeout (file:///C:/Users/Admin/Documents/Allegro/server/modules/allegroAPI.js:155:9)

y algo de codigo

 async request(path, method, payload) { if (this.props?.auth_token.expire <= Date.now()) return this.init(); const response = await fetch(this.props.api_url + path, { method, body: JSON.stringify(payload), headers: { "Content-Type": "application/vnd.allegro.public.v1+json", Accept: "application/vnd.allegro.public.v1+json", Authorization: `Bearer ${this.props.auth_token.token}`, }, }); let data = await response.json(); //line 90 return data; }
 async loopChestOrders() { setInterval(async () => { let data = await this.request( "order/checkout-forms?status=READY_FOR_PROCESSING&fulfillment.status=NEW", "GET" ); if (data.count > 0) { console.log("new order appears"); await this.sendPurchasedProducts(data); //line 155 } else { console.log("Looking for new purchases"); } }, 1000); } async sendPurchasedProducts(data) { let orders = data.checkoutForms; for (let order of orders) { const payloadProcessing = { status: "PROCESSING" }; await this.request(`order/checkout-forms/${order.id}/fulfillment`, "PUT", payloadProcessing); //line 166 const codes = [ { name: "TestCode", codes: ["Code", "Code"], } ]; const payloadSent = { status: "PICKED_UP" } sendMail(order.buyer.login, order.buyer.email, codes); await this.request( `order/checkout-forms/${order.id}/fulfillment`, "PUT", payloadSent ); } }

y la línea 166 se ejecuta correctamente antes del error porque los datos de solicitud recibidos de api también son correctos cuando se pasan a sendPurchasedProducts. Ocurre cuando {status: "processing"} o {status: "PICKED_UP"} está en el código, pero cuando elimino ambos códigos no arroja error. pero no puedo eliminarlo porque api no puede procesarlo sin ese JSON

about 4 years ago · Juan Pablo Isaza
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!