[Vuejs]-How can I handle async functions with axios vuejs

0👍

You need to return the Promise from getUsers().

Something like:

async getUsers(jwt) {
    apiUsers.defaults.headers.common['jwt'] = jwt
    return await apiUsers.get('/users').then((response) => {
      console.log('DATA RESPONSE 1', response.data)
      let data = response
      return data
    })
},

Please Note: You are not using async await nicely, for example, there is no need of awaiing the response in the above getUsers() you can simply return, whereas you can use async/await under your getUsers() of Users.vue.

Leave a comment