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