I would like to use this callback inside of a function that has a callback

I'm trying to receive a list of files using this block of code:

var templates;
db.getTemplates(function(err, reply){
    templates = reply;
});

from this block of code, but node is complaining "undefined is not a function", why is callback undefined? And more importantly what is the best way to write this?

function getTemplates(callback){
fs.readdir('views/templates', function(err, reply){
    if(err){
        callback('there was an error reading the directory: ' + err, null);
    } else{
        callback(null, reply);
    }
});
}

I found my issue. I had to place callback inside of an if statement to make the code run. Example:

function getTemplates(callback){
    fs.readdir('views/templates', function(err, reply){
    if(callback){    
        if(err){
            callback('there was an error reading the directory: ' + err, null);
        } else{
        callback(null, reply);
    }
}
});
}