• 로그인
  • 장바구니에 상품이 없습니다.

home2 게시판 Node.js, Express 게시판 HTML에 DB데이터 꽂아넣는 법 2 (DB데이터 읽기) 질문

HTML에 DB데이터 꽂아넣는 법 2 (DB데이터 읽기) 질문

2 글 보임 - 1 에서 2 까지 (총 2 중에서)
  • 글쓴이
  • #12049

    현승균
    참가자

    해당 과정에서 에러가 해결되지 않고 있습니다 ㅠㅠ

    구글링도 해보고 여러 시도도 해봤지만..뭐가 문제인지 도저히 모르겠습니다.... 도와주세요 ㅠㅠ

    server.js 코드

    app.get('/list',(req,res)=>{
        
        db.collection('post').find().toArray(function(err, res){
            console.log(res);
            console.log(err);    
            res.render('list.ejs', { posts : res});      
        }); 

    list.ejs 코드

          <h4>할일 제목 : <%= posts[0].제목 %></h4>
          <p>할일 마감날짜 : <%= posts[0].날짜 %></p>

     

    render쪽 코드를 ejs를 기입하며 function에 짚어넣기 전에는 localhost에 잘 표출 됩니다. 

    render쪽 코드에 ejs 를 쓰고 function 안쪽으로 넣으면 아래 err 코드가 뜨고.. 작동이 되지 않습니다. ㅠㅠ 도와주세요...

     

     

    아래 에러가 계속 표출됩니다.. 

    (node:5448) Warning: Accessing non-existent property 'MongoError' of module exports inside circular dependency
    (Use node --trace-warnings ... to show where the warning was created)
    (node:5448) DeprecationWarning: current Server Discovery and Monitoring engine is deprecated, and will be removed in a future version. To use the new Server Discover and Monitoring engine, pass option { useUnifiedTopology: true } to the MongoClient constructor.
    listening on 8080

    #12053

    codingapple
    키 마스터

    toArray(function(err, res) 이걸 res말고 다른걸로 작명해보십시오 app.get('/list',(req,res) 여기의 res와 겹쳐서 그런 것 같은데요 

    warning 메세지는 무시하셔도 됩니다 mongodb 라이브러리 버전 업데이트하면 해결됩니다 

     

2 글 보임 - 1 에서 2 까지 (총 2 중에서)
  • 답변은 로그인 후 가능합니다.

About

현재 월 700명 신규수강중입니다.

  (09:00~20:00) 빠른 상담은 카톡 플러스친구 코딩애플 (링크)
  admin@codingapple.com
  이용약관
ⓒ Codingapple, 강의 예제, 영상 복제 금지
top

© Codingapple, All rights reserved. 슈퍼로켓 에듀케이션 / 서울특별시 강동구 고덕로 19길 30 / 사업자등록번호 : 212-26-14752 온라인 교육학원업 / 통신판매업신고번호 : 제 2017-서울강동-0002 호 / 개인정보관리자 : 박종흠