diff --git a/lib/methods/index.js b/lib/methods/index.js index fd6971c..c31b603 100644 --- a/lib/methods/index.js +++ b/lib/methods/index.js @@ -32,7 +32,7 @@ const Methods = ({ return class methods { constructor () { - wires.register((...args) => this.test(...args)); + wires.register(async(...args) => await this.test(...args)); this.namespace = config?.namespace || ''; this.uid = uidCounter(); } @@ -170,7 +170,7 @@ const Methods = ({ let mr = data; try { if (mr.method === mr.meta?.caller) { // this is response, it calls auto generated fn that resolves promise only - return m.fn(data); + return await m.fn(data); } const r = await Promise.resolve( m.fn( @@ -188,7 +188,7 @@ const Methods = ({ mr.params = r; } catch (e) { mr.params = undefined; - mr.error = e?.error?.stack || e?.stack; + mr.error = e?.error?.stack || e?.stack || e?.error || e; this.log('error', 'Methods', mr.error, callData); } if (!data.id) {