loopbackjs - Loopback Remote Method Callback not working -
loopbackjs - Loopback Remote Method Callback not working -
okay citizens of internet, need help... super-simple remote method isn't firing callback. instead error message:
/maestro/common/models/datalog.js:11 cb(null, err || 'success'); ^ typeerror: undefined not function @ /maestro/common/models/datalog.js:11:11 the model:
module.exports = function(datalog) { datalog.logdata = function(description, errordetails, errormsg, severity, cb) { datalog.create( { description: description, errordetails: errordetails, errormsg: errormsg, severity: severity }, function(err, res) { cb(null, err || 'success'); } ); } datalog.remotemethod( 'logdata', { accepts: [ {arg: 'description', type: 'string'}, {arg: 'errordetails', type: 'string'}, {arg: 'errormsg', type: 'string'}, {arg: 'severity', type: 'string'} ], returns: {arg: 'log', type: 'string'} } ); }; the file calling method:
logdata = require('./server/server.js').models.datalog.logdata; logdata('my test success', '', 'test success', 'info'); why loopback not passing callback?
yes, remote method applies request through api endpoint. if you're calling directly, provide own callback.
loopbackjs strongloop
Comments
Post a Comment