Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 |
Tags
- generic
- app:compiledebugkotlin
- Next.js
- 상속
- set
- map
- Filter
- reactnative error
- 슬라이딩윈도우
- interface
- err_connection_refused
- javascript
- 이진탐색
- extends
- Spring
- reactnative
- mainapplication.kt
- array
- 리액트네이티브아이콘
- 스크롤이벤트
- async
- TS
- 타입스크립트
- materialicons
- 안드로이드빌드에러
- npm에러
- forwardref type
- app.post
- 배열중복요소제거
- react
Archives
- Today
- Total
rhanziy
node.js - detail 상세페이지(params.id) 본문
삭제기능을 구현했으니 상세페이지를 만들어보자.
/detail/게시물id 번호 url로 접속하면 detail.ejs페이지를 보여주는 코드.
app.get('/detail/:id', (req, res)=>{
db.collection('post').findOne({ _id : parseInt(req.params.id) }, (error, result)=>{
res.render('detail.ejs', { data : result })
})
역시나 id 데이터타입은 int형이므로 parseInt로 변환해서 찾기
+ ejs파일에서 중복되는 navbar를 html파일로 만들어 조립식으로 끼워보자
간단히 한줄만 추가해주면 됨.
<%- include('nav.html') %>
'Node.js' 카테고리의 다른 글
node.js - session 방식으로 로그인 구현하기 (1) | 2023.03.20 |
---|---|
node.js - method-override 라이브러리 PUT 구현 (0) | 2023.03.20 |
node.js - ajax 삭제요청 (0) | 2023.03.20 |
mongoDB에 id값 auto increase 구현 (0) | 2023.01.17 |
node.js - app.post 구현하고 ejs라이브러리 설치 (2) | 2023.01.15 |
Comments