Skip to content
This repository has been archived by the owner on Feb 4, 2022. It is now read-only.

Exemple using cookie-universal-nuxt #444

Open
mrleblanc101 opened this issue Feb 1, 2022 · 1 comment
Open

Exemple using cookie-universal-nuxt #444

mrleblanc101 opened this issue Feb 1, 2022 · 1 comment

Comments

@mrleblanc101
Copy link

Would it be possible to add an exemple using cookie-universal-nuxt instead of cookie and js-cookies. It combine both feature into a single plugin and is already a Nuxt module.

@mrleblanc101
Copy link
Author

I think we can just do this, but I'm not sure it will handle every edge case:

// ~/plugins/persistedState.js

import createPersistedState from 'vuex-persistedstate';

export default ({ store, $cookies }) => {
    createPersistedState({
        paths: [...],
        storage: {
            getItem: (key) => $cookies.get(key),
            setItem: (key, value) => $cookies.set(key, value, { expires: 365, secure: false }),
            removeItem: key => $cookies.remove(key)
        }
    })(store);
};

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant