[NODE 강의] body-parser?
[클립명] 1. form (body-parser) 2. 정적파일 3. Global View Variable body-parser란? body-parser는 미들웨어이다. 즉, 요청(request)과 응답(response) 사이에서 공통적인 기능을 수행하는 소프트웨어이다. 그렇다면 역할은 무엇일까? 바로 요청의 본문을 지정한 형태로 파싱해주는 미들웨어이다. 아래의 테스트 코드에서 req.body를 콘솔로그로 출력해보면 undefined가 출력된다. 즉, Node.js의 웹프레임워크인 Express는 요청을 처리할 때 기본적으로 body를 undefined로 처리하고 있는 것이다. app.get('/test', (req, res) => { res.send('test'); console.log(req.body..
2021.03.03