Answer the question
In order to leave comments, you need to log in
How to read cookie/localStorage before creating Vue component?
Just starting to learn about cookies and how to work with them. When creating a component, I want to check whether there is a necessary cookie and if the result is successful / not successful, display different information. But I can only do this at the beforeMount() stage. When using check in created() it writes localStorage or document is not defined. How can and can this problem be solved?
In the project I used vue-cookie and localStorage.setItem(key) on a nuxt project.
Answer the question
In order to leave comments, you need to log in
created() writes localStorage or document is not defined <...> nuxt
if (process.client) {
// здесь можете пощупать localStorage
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question