Returning Promises from Vuex actions

Returning Promises from Vuex actions

Asked on November 22, 2018 in vue.js.
Add Comment


  • 1 Answer(s)

    There is no need to generate promise, axios sends unique itself:

    Sample:

    export const loginForm = ({commit},data) => {
            return axios.post('http://localhost:8000/api/login',data).then((response) => {
                console.log(response);
                commit('logUserIn',response.data.data);
            }).catch((error) => {
                commit('unAuthorisedUser',{
                    error:error.response.data
                })
            })
    };
    
    Answered on November 22, 2018.
    Add Comment


  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.