[Dev] res.send(), res.json(), res.end()

Daily Dev Blog .·2021년 12월 12일
0

DEV

목록 보기
4/5
post-thumbnail

res.send(): send에 전해진 argument에 따라서 Content-type이 자동적으로 만들어진다.

res.json(): json이 아닌 것도 json 형식으로 바꾸어서 보내준다. 즉 content-type 헤더를 application/JSON으로 고정한다. 그런데 결국 res.json()도 마지막에 res.send()를 호출한다.

res.end(): 보내줄 아무 데이터도 없는데 response를 끝내고 싶을 때 사용한다.
ex) res.status(400).end();

profile
Better Than Yesterday🌳

0개의 댓글