Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

131
Views
accessing `this` inside async functions in methods of vue.js

I have a vue.js class method that needs to call on an async function using await:

methods: {
   playRecording(path) {
      return await this.getAudioUrl(path)
   }
}

This results in the following error:

Unexpected reserved word 'await'.

In order to fix this error, I re-wrote the code using async as such:

methods: {
    playRecording : async() => {
       console.log(this) // `this` evaluates to `undefined`
       var path = '/recordings/' + this.book
       return await this.getAudioUrl(path)
    }
}

While this does address the await error above, it results in a new error:

Cannot read properties of undefined (reading 'book')

this evaluates to undefined

How can I regain access to this inside a class method marked with async?

about 4 years ago · Santiago Gelvez
1 answers
Answer question

0

The calling method has to be defined as such:

async playRecording () {

This is incorrect:

playRecording : async() => {
about 4 years ago · Santiago Gelvez Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!