Aurelia dialog & Typescript async await - Cannot find name 'await'

Viewed 436

I'm having problems using async await together with Aurelia Dialog. Basically I want to send away a request when the dialog is closed and currently it gives me syntax error:

Cannot find name 'await'

If I move the request outside the .WhenClosed function I dont get any syntax error and I can fire away a request.

Cannot find name 'await'

Why is it that I can't use async await inside the .whenClosed dialog and how can I overcome this?

2 Answers

The arrow function you pass to to whenClosed has to be async

async response => {}

Maybe you should try to use

.whenClose(async (response) => { let result_2 = await this.organisationService... })

to instead~

Related