Tuesday 6 June 2017

How call a function in node js? [duplicate]

This question already has an answer here:

I'm having a problem with node JS.

Basically,I Have this function :

let getImageName = function(query,callback){
  Images.getImageById(query,function(err,image){
    return image.filename;
  });
}

But when i called this,the console.log() print undefined,and I know that the function getImageName is working.

app.get('/api/books/:_id', function(req, res){
Book.getBookById(req.params._id, function(err,book){
    if(err){
        throw err;
    }
    console.log(getImageName(book.cover));
});
});



via Diego Oliveira

No comments:

Post a Comment