0

I'm trying to display some user's information in a HTML from MongoDB. For the connection to the DB, I'm using Node.js.

I want to display that info, after clicking a button (POST):

var mongoose = require('mongoose');
var express = require('express');
var app=express();
//para parsear el contenido del post
var bodyParser = require('body-parser');

mongoose.Promise = global.Promise
mongoose.connect("mongodb://localhost/myDB");

app.use(bodyParser.json());
app.use(bodyParser.urlencoded({extended: true}));




var usuarioSchema = ({
    email:String,
    nick:String,
    nombre:String,
    pass:String

});

//creamos un usuario con las caracteristicas del scehma
var Usuario = mongoose.model("Usuario",usuarioSchema);

app.use(express.static("public"));

//esto solo carga el index.html
app.get("/",function(solicitud,respuesta){

respuesta.sendFile('/nanana/na/volcadoBD.html');
});

app.post("/volcado",function(solicitud,respuesta){

    Usuario.find(function(error,documento){
        if(error){console.log(error);}

        else{
            console.log(documento);
            respuesta.sendFile('/nanana/na/volcadoHTML.html', {usu: documento});

        }

    });

});

I want to display all the user fields in a basic HTML but I don't know how to do it :(

this is volcadoHTML:

<html>
<head>
    <title></title>
</head>
<body>
    <div>{{#each items}}
    </div>


</body>
</html>

someone can help me please?

thank you a lot

  • Any issues/errors? Please share the `volcadoHTML.html` of the page. – Searching Jan 14 '17 at 18:53
  • Updated, I dont have anything in there –  Jan 14 '17 at 19:08
  • Hmmm nothing there. Try this answer http://stackoverflow.com/a/19913691/1339516. You are missing view engine to tell express how/what should happen with variables on the page https://expressjs.com/en/guide/using-template-engines.html – Searching Jan 14 '17 at 19:18

0 Answers0