如何await使用with或withasync调用函数?callapplyBabel
下面是一个示例,其中getOrders是类的async方法Service:
class Service() {
async getOrders(arg1, arg2, arg3) {
return await this.anotherService.getOrders(arg1, arg2, arg3);
}
}
let service = new Service();
// ...
// Babel doesn't compile
// let stream = await service.getOrders.call(this, arg1, arg2, arg3);
// producing SyntaxError: Unexpected token for await
let stream = service.getOrders.call(this, arg1, arg2, arg3);
stream.pipe(res); // obviously not working without await in the prev line