Skip to content
Advertisement

Vuex-persist throws Uncaught TypeError: s is not a function

Here is my code: I don’t know exactly what the problem is, maybe someone knows how to fix it!

const vuexLocal = new window.VuexPersistence.VuexPersistence({
    storage: window.localStorage,
});
const visits = {
    state: {
        visit: []
    },
    mutations: {
        addVisit(state, data) {
            state.visit.push({
                    "id": data["id"],
                    "full_name": data["full_name"],
                    "entranceweight": data["entranceweight"],
                    "dispatched": data["dispatched"],
                    "vehicletype": data["vehicletype"],
                });
        },
    },
};
const visitStore = new Vuex.Store({

    modules: {
        visit: visits,
    },

    plugins: [ vuexLocal.plugin, ]
});

it says Uncaught TypeError: s is not a function | vuex-persist.js 1:657

Advertisement

Answer

I ran into a similar issue recently as well. It seems to me that the newest build is unstable and is causing this issue. If you’re updating directly in browser, you’ll need to import the last stable version.

<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.10/lodash.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/vuex-persist@2.2.0"></script>

I’ve also submitted the issue to the repo, but this was a way to get around it for now.

https://github.com/championswimmer/vuex-persist/issues/201

Advertisement