Riya Singhal Riya Singhal - 3 years ago 207
Javascript Question

how can i get the fetched record in route model node js

I am getting the fetch records on console, but I want to access on route page.

module.exports.getcoin_info = function(err,callback){
var results = [];

throw err;



route page in this function I am not getting records. Please guide me how it will proceed if there are any another way for the same please guide me.

monogoose_user.getcoin_info(function(err, results) {
if (err) {
} else {

Answer Source

Why not do the following?

module.exports.getcoin_info = function(callback) {
    coin_model.find(function(err, teams) {
        callback(err, teams);

This way you will be able to access both the error and teams in your callback.

Basically you are just calling the callback function with 2 parameters (err and teams) after it's done searching the DB.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download