Vuex Laravel Loads all data

  laravel, php, vue.js, vuex

I’ve been trying to load all of my data when the time I log in. Currently, I’ve only managed to display data through the console through vuex file. I just want to achieve this because wherever it loads all data when login, it will easier for me to call every function on every page.

I think the first step is to display it on vue devtools?

This is what I’ve tried.
I have this file on my "./store/modules/currentUser.js"

import axios from "axios";
const state = {
};
const getters = {};
const actions = {
    loadEmployee({}){
        axios.post(BASE_URL + '/transportation/driver/autoComplete').then(response => {
            console.log(response.data); // how to pass result to devtools?
        });
    }
};
const mutations = {};

export default {
    namespaced: true,
    state,
    getters,
    actions,
    mutations

}

Login.vue

<script>
export default {
    data () {
        return {
            listdata:[]
        }
    },
    methods: {
        login() {
            this.$store.dispatch('currentUser/loadEmployee', this.listdata);
        }
    }
}
</script>

This is my vuedevtools looks like

enter image description here

And I want to fetch all data on listdata array vue devtools

enter image description here

Source: Laravel

Leave a Reply