Click here to Skip to main content
15,900,973 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi everyone, Im tryingto to list the data coming from the mongo db in a file handlebars. But the problem is that when I load the screen, only the message "Category Listing" appears and the names of the categories do not appear as requested:

{{#each erros}}
{{texto}}

{{else}}

{{/each}}

To create the modell and the collection, I used:

var conexao = require("../config/conexao")

var CategoriaSchema = conexao.Schema({

nome:{
type: String,
require: true
},

slug:{
type: String,
require: true
},

date:{
type: Date,
default: Date.now()
}

})

module.exports = conexao.model("Categorias", CategoriaSchema)


And in the main file, to render the handlebars file, I used:

const express = require("express");
const handlebars = require("express-handlebars");
const app = express();
const Handlebars = require('handlebars')
const Categorias = require("./models/Categoria")

app.get("/", (req, res) =>{
    Categorias.find().then((categorias) =>{
        res.render("listaCategorias", {categorias: Categorias})
    }).catch((erro) => {
        (colsole.log(erro))
        res.redirect("/cadastrar")
    })
})


Can anybody help me?


What I have tried:

No error appears on the console, but when loading the screen, only the title "Category Listing" appears and it does not list the categories.
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900