【问题标题】:How to return async result from a method? [duplicate]如何从方法返回异步结果? [复制]
【发布时间】:2016-10-28 14:39:39
【问题描述】:

我正在尝试从异步回调函数返回的 Meteor.method 返回一个值,如下所示:

Meteor.method('myMethod', () => {
    asyncFunction(result => {
        // Meteor.method should return this result
    });
});

我应该把return result; 声明放在哪里?

【问题讨论】:

标签: javascript asynchronous meteor callback


【解决方案1】:

你可以试试这个:

Meteor.method('myMethod', () => {
    return asyncFunction(result => {
        // Meteor.method should return this result
return result;
    });
});

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-07-14
    • 2023-04-01
    • 1970-01-01
    • 1970-01-01
    • 2018-09-01
    • 2019-09-05
    相关资源
    最近更新 更多