작성
·
191
0
안녕하세요.
현재 백엔드 서버, 프론드서버를 모두 npm run dev로 킨 상태입니다. 또한 msSQL 도 running을 확인했습니다.
workbench를 통해 user 테이블이 생성된 것 까지 확인된 상태입니다.
회원가입을 하게 되면, terminal 창에 아래와 같은 500에러가 발생합니다.
백엔드에서도 console.log로 이메일, 패스워드를 찍었는데, undefined가 되어있어서 데이터가 안 넘어가는 상태로 생각하고 있습니다. (프론트에서는 payload에 값이 다 잘 들어있습니다.)
무엇이 문제인지 알고싶습니다.
Executing (default): SELECT `id`, `email`, `nickname`, `password`, `createdAt`, `updatedAt` FROM `Users` AS `User` WHERE `User`.`email` = 'dog@dog.dog';
{ SequelizeValidationError: notNull Violation: User.email cannot be null,
notNull Violation: User.nickname cannot be null,
notNull Violation: User.password cannot be null
name: 'SequelizeValidationError',
답변 4
1
db.User.create에는 where 넣지말고 바로 값 넣으셔야 합니다.
1
POST /user 라우터에서 req.body.email, req.body.password가 undefined였다는 말씀이신가요? 그런 경우는 express.json(), express.urlencoded() 설정이 제대로 되어있는지 봐야 합니다.
0
0
위의 코드로 실행을 하면, 아래와 같이 req.body에 값이 정상적으로 들어가있습니다.
그런데 바로 밑에 User.email cannot be null,가 되면 안된다는 에러가 발생합니다.
reqqqqqqqqqqqqq { email: 'dog@dog.dog',
nickname: '강아지',
password: 'q1w2e3r41234' }
Executing (default): SELECT `id`, `email`, `nickname`, `password`, `createdAt`, `updatedAt` FROM
`Users` AS `User` WHERE `User`.`email` = 'dog@dog.dog';
{ SequelizeValidationError: notNull Violation: User.email cannot be null,
notNull Violation: User.nickname cannot be null,
notNull Violation: User.password cannot be null