728x90
반응형
nunjucks 는 html에 변수를 넘겨줄 수 있다.
// node.js
mysql.createConnection('select date_format(날짜, "%y-%m-%d %T") as date from 테이블', (error, results)=>{
if(error){
//error
}
else{
응답.render('html파일',{
변수:results,
}
})
// html
{% for item in 변수 %}
<div>{{ item.date }}</div>
{% endfor %}
반응형
'Back_end > node.js' 카테고리의 다른 글
node.js) 미들웨어 기초 및 사용 (0) | 2021.04.27 |
---|---|
node.js) redirect() (0) | 2021.04.25 |
node.js) nunjucks (html에 값 전달) (0) | 2021.04.22 |
node.js ) mysql 연결 및 사용(maria DB) (0) | 2021.04.22 |
node.js) 환경변수 설정 (dotenv) (0) | 2021.04.21 |
댓글