Node.js 无法将数据从我的数据库获取到swig模板中

Node.js 无法将数据从我的数据库获取到swig模板中,node.js,express,Node.js,Express,我正在处理一个项目,不明白为什么在我将console.log登录到我的视图时无法获取当前的数据。这是我的路线文件: var express = require('express'); var router = express.Router(); var models = require('../models'); router.get('/', function(req, res) { models.Destination.find(function(err, results) {

我正在处理一个项目,不明白为什么在我将console.log登录到我的视图时无法获取当前的数据。这是我的路线文件:

var express = require('express');
var router = express.Router();
var models = require('../models');



router.get('/', function(req, res) {
  models.Destination.find(function(err, results) {
    console.log(results); // THIS HAS ALL MY DATA
    res.render('index', { destination: results, title: "Practice App" });

    });
});

module.exports = router;

Here is my index.html view file:

{% extends "layout.html" %}

{% block content %}
    <h1>{{title}}</h1>
    <p>Welcome to {{title}}</p>
    <h1>{{destination}}</h1>
{% endblock %}

为什么即使我在上面的console.log行中记录了所有数据,我也无法访问来自数据库的结果值?

应用程序崩溃时是否会发出错误消息?包含它们将有助于调试您的问题。“结果”是数组吗?我对swig没有太多经验,但从它的文档来看,它使用“for..in”循环打印数组中的值。如果您直接要求它打印阵列,可能会出现问题。
res.render('index', { destination: results, title: "Practice App" })