node.js - how do I use res.render with mongoose find function? -
i have route gets of clients in mongodb , returns them. when try use res.render() mongoose find() callback, error saying referenceerror: res not defined
here's code works , i've confirmed returning clients:
app.get( '/clients', function( request, response ) { return clientmodel.find( function( err, clients ) { if( !err ) { return response.send( clients ); } else { return console.log( err ); } }); }); here's code i'm trying use render ejs view, while passing list of clients:
app.get( '/clients', function( request, response ) { return clientmodel.find( function( err, clients ) { if( !err ) { res.render('clients/clients.ejs', { clients: clients }); } else { return console.log( err ); } }); }); how can work?
use response.render instead of res.render.
Comments
Post a Comment