У меня есть следующий код:
Orders.js
'use strict';
var OrderService = require('../services/OrderService');
module.exports = function(Orders) {
var orderService = new OrderService(Orders);
Orders.history = function(data, cb) {
console.log("getting history");
orderService.getHistory(data, cb)
.catch(err => cb(err));
};
Orders.remoteMethod('history', {
http: { verb: 'get', path: '/:token/history' },
accepts: [
{ arg: "token", type: "string", required: true },
{ arg: "base_token", type: "string", required: true }
],
returns: { type: 'object', root: true }
});
};
Orderservice.js
function OrderService(Orders){
}
OrderService.prototype.getHistory = async function(token, baseToken, callback){
<some operation>
callback(null, this.validatorService.finalize(buyResult));
}
Когда я нажимаю на этот API, я получаю следующую ошибку
node:1996) UnhandledPromiseRejectionWarning: TypeError: cb is not a function
at orderService.getHistory.catch.err (/usr/app/server/models/orders.js:12:18)
at processTicksAndRejections (internal/process/next_tick.js:81:5)
(node:1996) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
| (node:1996) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
У меня есть аналогичный код для других моделей и служб, что мне не хватает?