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

280
Views
SyntaxError: Token inesperado 2 en JSON en la posición 0

Estaba enviando datos desde el sitio del cliente => servidor => base de datos. Pero el error ocurre en la terminal del lado del servidor.

 syntaxError: Unexpected token 2 in JSON at position 0 at JSON.parse (<anonymous>) at createStrictSyntaxError (C:\Users\ANUPAM\Desktop\assigment\assigment-11\book-hut-server\node_modules\body-parser\lib\types\json.js:160:10) at parse (C:\Users\ANUPAM\Desktop\assigment\assigment-11\book-hut-server\node_modules\body-parser\lib\types\json.js:83:1S) at C:\Users\ANUPAM\Desktop\assigment\assigment-11\book-hut-server\node_modules\body-parser\lib\read.js:128:18 at AsyncResource.runInAsyncScope (node:async_hooks:199:9) at invokeCallback (C:\Users\ANUPAM\Desktop\assigment\assigment-11\book-hut-server\node_modules\raw-body\index.js:231:16) at done (C:\Users\ANUPAM\Desktop\assigment\assigment-11\book-hut-server\node_modules\raw-body\index.js:220:7) at IncomingMessage.onEnd (C:\Users\ANUPAM\Desktop\assigment\assigment-11\book-hut-server\node_modules\raw-body\index.js:280:7) at IncomingMessage.emit (node:events:402:35) at endReadableNT (node:internal/streams/readable:1343:12)

Este es mi código del lado del cliente.

 fetch(putUrl, { method: "PUT", headers: { 'content-type': 'application/json' }, body: JSON.stringify(newQuantity) })

Este es el código del lado del servidor

 app.put('/update/:id', async (req, res) => { res.send('Go') })
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!