• Jobs
  • About Us
  • professionals
    • Home
    • Jobs
    • Courses and challenges
  • business
    • Home
    • Post vacancy
    • Our process
    • Pricing
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Salary Calculator

0

224
Views
SyntaxError: Unexpected token 2 in JSON at position 0

I was Sending data from CLient Site => server => Data Base. But The error happens on the serverside's terminal.

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)

This is my client-side Code.

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

This is server-side code

app.put('/update/:id', async (req, res) => {
            res.send('Go')
        })
about 3 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 Our process Sales
Legal
Terms and conditions Privacy policy
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recommend me some offers
I have an error