Skip to Content
한 권으로 끝내는 Node & Express(2판): 모던 웹을 위한 서버 사이드 자바스크립트의 모든 것
book

한 권으로 끝내는 Node & Express(2판): 모던 웹을 위한 서버 사이드 자바스크립트의 모든 것

by 한선용, 이선 브라운
May 2021
Beginner to intermediate
448 pages
9h 47m
Korean
Hanbit Media, Inc.
Content preview from 한 권으로 끝내는 Node & Express(2판): 모던 웹을 위한 서버 사이드 자바스크립트의 모든 것
115
6
요청과 응답 객체
6.10.1
콘텐츠 렌더링
콘텐츠를 렌더링할 때는 뷰를 레이아웃 안에 렌더링하는
res
.
render
를 가장 자주 사용합니
다. 이따금 테스트 페이지를 빨리 만들어보고 싶을 때는
res
.
send
를 사용합니다.
req
.
query
로 쿼리스트링 값을 가져오거나,
req
.
session
으로 세션 값을 가져오거나,
req
.
cookie
/
req
.
signedCookies
로 쿠키를 가져옵니다. [예제
6
-
1
]부터 [예제
6
-
8
]까지는 일반적인 콘텐츠 렌
더링 작업에 관한 예제입니다.
예제
6-1
기본 사용법(
ch06
/
02
-
basic
-
rendering
.
js
)
// 기본 사용법
app.get(‘/about’, (req, res) => {
res.render(‘about’)
})
예제
6-2
200
이외의 응답 코드(
ch06
/
03
-
different
-
response
-
codes
.
js
)
app.get(‘/error’, (req, res) => {
res.status(500)
res.render(‘error’)
})
// 다음과 같이 한 줄로 쓸 수도 있습니다.
app.get(‘/error’, (req, res) => res.status(500).render(‘error’))
예제
6-3
뷰에 쿼리스트링, 쿠키, 세션 값 등의 콘텍스트 전달(
ch06
/
04
-
view
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

한 권으로 끝내는 Node & Express: 웹사이트 구축을 위한 서버 사이드 자바스크립트

한 권으로 끝내는 Node & Express: 웹사이트 구축을 위한 서버 사이드 자바스크립트

한성용, 이선 브라운

Publisher Resources

ISBN: 9791162244227