Vietnam

    Nodejs.vn

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Popular
    • Tags
    • Groups
    • Search

    Lỗi Cannot read property 'length' of undefined

    Hỏi Đáp
    0
    1
    598
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • N
      ngodoanluong last edited by

      Chào mọi người! Em mới học về nodejs và đang làm 1 project nhỏ về bằng expressjs . Em có 2 đoạn code sau và nó luôn báo lỗi cannt read . Mong mọi người giúp đỡ.
      Code trong file index.js
      router.get('/', function(req, res, next) {
      var collection = req.db.get('book');
      collection.find({}, {}, function(e, docs) {
      res.render('index', {
      "list_book" : docs
      });
      });
      });

      Code trong file index.jade
      each book in list_book
      #book
      //a(href='#')
      img(src=book.img)
      #book-list
      h3=book.name

      1 Reply Last reply Reply Quote 0
      • First post
        Last post