I am trying to learn loopback but I don't really understand what 'cb' means in function call. I read this In loopback documentation what does variable 'cb' stands for? and I have basic understanding of callback in nodejs but I just don't understand cb in loopback. For example, http://docs.strongloop.com/display/public/LB/Remote+methods.
module.exports = function(Person){
Person.greet = function(msg, cb) {
cb(null, 'Greetings... ' + msg);
}
Person.remoteMethod(
'greet',
{
accepts: {arg: 'msg', type: 'string'},
returns: {arg: 'greeting', type: 'string'}
}
);
};
What does that cb mean? How can we know it accepts two parameters, null and a string? Hope someone could help.
cb
stands for callback, nothing special, just avariable name, can be replaced by any other variable name – Creek