[Vuejs]-Then () function is not executed in vue store function

1👍

You should use the async and await keywords.

async loadPosts({ commit, state }, payload) {
        console.log("loadPosts check 1111");
        if (state.hasMorePost) {
            console.log("loadPosts check 2222");
            await this.$axios.get(`http://localhost:3085/posts?offset=${state.mainPosts.length}&limit=10`)
            .then((res) => {
                console.log("res : ", res);
                    commit('loadPosts', res.data);
                }).catch((err) => {
                    console.log("err : ", err);
                });
        }
    },

Leave a comment