인프런 커뮤니티 질문&답변
node server.js 명령어를 입력하면 오류가 나옵니다
작성
·
284
1
SyntaxError: Unexpected string in JSON at position 49
at JSON.parse (<anonymous>)
at parse (C:\Users\김성범\Desktop\cap-server\node_modules\body-parser\lib\types\json.js:89:19)
at C:\Users\김성범\Desktop\cap-server\node_modules\body-parser\lib\read.js:121:18
at invokeCallback (C:\Users\김성범\Desktop\cap-server\node_modules\raw-body\index.js:224:16)
at done (C:\Users\김성범\Desktop\cap-server\node_modules\raw-body\index.js:213:7)
at IncomingMessage.onEnd (C:\Users\김성범\Desktop\cap-server\node_modules\raw-body\index.js:273:7)
at IncomingMessage.emit (events.js:327:22)
at endReadableNT (internal/streams/readable.js:1327:12)
at processTicksAndRejections (internal/process/task_queues.js:80:21)
QUERY : {}
QUERY : {}
답변 1
0
49번째 줄에 JSON이 제대로 들어오지 않는 문제같아요.
JSON.parse를 할 때 안에 들어가는 string 값이 JSON 형식에 맞게 적혀져 있어야 합니다!
JSON.parse 안에 들어갈 값을 console.log로 찍어서 먼저 확인해보세요 :)
안되시면 소스코드와 로그 남겨주시구요.





소스코드