Using async await to get data loading

Viewed 182

I try use async-await to get data on typescript vue 3, but this function already console when the data is undefined (or before function call working)

private async exportDataOrder() {
    await this.getDataExport()                          // function call
    let data = await this.controller.exportOrderData    // result function
    if (data) {
      console.log(data, 'dari vue')
      console.log('waiting')
    }
}
1 Answers

Assuming that exportOrderData is an async function, you forgot the () to actually call your function.

let data = await this.controller.exportOrderData()
Related