강의

멘토링

커뮤니티

Inflearn Community Q&A

roseonghwan1342's profile image
roseonghwan1342

asked

Node and React series that you can learn by following - Basic lecture

Node React Basics Lecture #13 Creating Auth Function

res.status(200) 또는 400

Written on

·

586

0

안녕하세요 강사님. 강의 잘 듣고 있습니다!

궁금한 점이 하나 있어서 여쭤보려고 합니다.

조건문에 따라 각각 res를 이용해서 json형식으로 결과를 나타내고 있었는데

신호가 잘 도착했을 때 res.json({... 또는  res.status(200).json({... 이런 형식이고 실패할 때는 res.json({... 또는 res.status(400).json({... 이런 형식이던데 어떨 때 status()를 표시하거나 표시하지 않아야 하나요?

nodejsreact

Answer 1

1

John Ahn님의 프로필 이미지
John Ahn
Instructor

안녕하세요 

status는 상태를 임의로 보내줄 때 사용하시면 됩니다.

(그러므로 보내줘도 되고 안보 내줘도 됩니다 옵션입니다.) 

200번대는 성공이며 400번대는 클라이언트 에러 500번대는 서버 에러입니다.

감사합니다.
참조: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status

roseonghwan1342's profile image
roseonghwan1342

asked

Ask a question