-
SyntaxError: Unexpected string in JSON at position 23, at JSON.parse (<anonymous>)Error Handling/에러핸들링 2023. 7. 6. 17:27
에러내용
at JSON.parse (<anonymous>) at parse (C:\Users\admin\Desktop\코딩\NODE\4th Week\Sequelize-Relations (Lv.4)\node_modules\body-parser\lib\types\json.js:89:19) at C:\Users\admin\Desktop\코딩\NODE\4th Week\Sequelize-Relations (Lv.4)\node_modules\body-parser\lib\read.js:128:18 at AsyncResource.runInAsyncScope (node:async_hooks:203:9) at invokeCallback (C:\Users\admin\Desktop\코딩\NODE\4th Week\Sequelize-Relations (Lv.4)\node_modules\raw-body\index.js:231:16) at done (C:\Users\admin\Desktop\코딩\NODE\4th Week\Sequelize-Relations (Lv.4)\node_modules\raw-body\index.js:220:7) at IncomingMessage.onEnd (C:\Users\admin\Desktop\코딩\NODE\4th Week\Sequelize-Relations (Lv.4)\node_modules\raw-body\index.js:280:7) at IncomingMessage.emit (node:events:513:28) at endReadableNT (node:internal/streams/readable:1359:12) at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
SyntaxError: Unexpected string in JSON at position 23 at JSON.parse (<anonymous>) Executing (default): SELECT `userId`, `email`, `password`, `nickname`, `age`, `gender`, `profileImage`, `createdAt`, `updatedAt` FROM `Users` AS `Users` WHERE `Users`.`email` = '12sf3123'; Executing (default): SELECT `userId`, `email`, `password`, `nickname`, `age`, `gender`, `profileImage`, `createdAt`, `updatedAt` FROM `Users` AS `Users` WHERE `Users`.`email` = '12sf3123'; Executing (default): INSERT INTO `Users` (`userId`,`email`,`password`,`nickname`,`age`,`gender`,`profileImage`,`createdAt`,`updatedAt`) VALUES (DEFAULT,?,?,?,?,?,?,?,?);
app.js하고 썬더클라이언트에서 무언가 실행하려고 할때 이 에러가 났다.
원인은 단순하다. cofirmPassword다음에 쉼표를 안썻다.
뿐만아니라 위에 url쓸때 뒤에 빈칸이 한칸이라도 있어서는 안되고, body입력할때 중간에 당연히 쉼표가 빠져서는 안되고, 마지막에 쉼표는 꼭 빼야한다. 그리고 문자열인지 숫자열인지 모델에 정의된대로 작성해야 한다.
'Error Handling > 에러핸들링' 카테고리의 다른 글