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')
})