trying to build a generic function that calls async functions dynamically.
//passing the controller and functionName (string)
function asyncAwaitCaller(controller, functionName) {
let result = await controller[functionName];
}
and in my controller :
async dummyFunction() {
return "dummy";
}
but I get the following error :
SyntaxError: await is only valid in async function
Is there a way around this, because this works fine with Promises.
asyncif you implementawaitasyncAwaitCallerhas to beasyncin order to useawaitasync function asyncAwaitCaller...asyncdecorator means "inside this function I am declaring you will find anawaitand when you do, stop executing and await the response."