Answer the question
In order to leave comments, you need to log in
How to fix this error in node.js SyntaxError: Unexpected token " in JSON at position 0?
Good morning. Please tell me where this symbol comes from and how to solve this problem in the root?
Here I am submitting a request
async function findCompany(url,id) {
this.url = url
this.id = id
this.options = {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(this.id)
}
const response = await fetch(this.url,this.options)
const data = await response.json()
if(data) {
changeCompany('/control-company')
}
else {
$('.company-data').css('display','flex')
}
}
SyntaxError: Unexpected token " in JSON at position 0
at JSON.parse ()
at createStrictSyntaxError (C:\Users\History\Desktop\session\node_modules\body-parser\lib\types\json.js:158:10)
at parse (C:\Users\History\Desktop\session\node_modules\body-parser\lib\types\json.js:83:15)
at C:\Users\History\Desktop\session\node_modules\body-parser\lib\ read.js:121:18
at invokeCallback (C:\Users\History\Desktop\session\node_modules\raw-body\index.js:224:16)
at done (C:\Users\History\Desktop\session\node_modules \raw-body\index.js:213:7)
at IncomingMessage.onEnd (C:\Users\History\Desktop\session\node_modules\raw-body\index.js:273:7)
at IncomingMessage.emit(events. js:203:15)
at endReadableNT (_stream_readable.js:1145:12)
at process._tickCallback (internal/process/next_tick.js:63:19)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question