async/await actions in Vuex async/await actions in Vuex vue.js vue.js

async/await actions in Vuex


You're not awaiting the Vue.http.get() promise in the getResource() method, so await dispatch('getResource') will resolve before the HTTP request has resolved.

Trimmed down:

async getResource() {    let response    try {        response = await Vue.http.get('https://mysite/api/getResource')    } catch (ex) {        // Handle error        return    }    // Handle success    const data = response.body}