Await on an async function called with call or apply with Babel
An async function
returns a Promise, and await
accepts a promise. There is no requirement that all async
functions be called via await. If you want to use an async function inside a standard JS function, you would directly use the result promise. In your case, calling a function with .call
will still return a promise like any other function, so you'd they pass that promise to await:
async function doThing(){
let service = new Service();
var stream = await service.getOrders.call(this, arg1, arg2, arg3)
stream.pipe(res);
}