Skip to content
Advertisement

Tag: vuex

Vuex Method-style Access Getters

I am having a bit hard time understanding the following JS: These two code snippets are taken from official Vuex Documentation on Method Style Access for Getters. Now what I dont understand is, how those the second part of code output the value in the comment? Maybe I miss-understood JS functions? I believe the output would be: So actually the

Undefined when i am returning an Object in Javascript

I’m doing a getter in VueX, and when i’m returning an object for another function, i have “undefined”. Basically i have a function like that. When i’m showing obj with console.log(obj), i have an object with elements in here. And basically it’s working. But when i’m doing a return and i’m trying to get the obj in another function I

Wait for axios API call in vuex to finish before continuing vue-router guard

I have a django-rest-axios-vuejs application stack for which I’m trying to do something in the vue-router. In the vue-router beforeEach guard, I’m verifying permissions and it is done by checking something in an object called me in vuex store. Everything works well except when I refresh the page. Indeed refreshing the page also clears vuex store and my beforeEach tries

localstorage.getItem() not working in NUXT JS

I am trying to develop a shopping cart with nuxt js. I am successfully storing the cart data in local storage but I am unable to retrieve the data. N.B: i don’t wanna use vuex-persistedstate. Answer I see lots of small problems with this. First of all, it looks like you’ve put addToCart and saveInLocalStorage judging by the fact you

Cannot Delete and getting 404 not found error in router.delete

In my application, i am passing the request param id in router.delete and communicating that with vuex service. While triggering action api is fired but getting 404 not found and there is not request payload as well. Express route.delete Vuex service vuex actions component action trigger It is showing in api response server.js Answer Since your api endpoint is this:

Mutate Vuex array passed in the payload

What’s the technical difference between next two approaches? Example is trivial but when I have huge nested objects, I need to pass lots of IDs in order to find desired object inside the mutation. In second example I pass an array and just mutate it. Again, technically in both examples we invoke the same push method. Am I right? Should

Vuex 4, State is empty in component

I am trying to access subjects store state using this.$store.state.subjects inside my home component however it comes up as an empty array. Using console.log the only place I am able to see the state.subjects populated is if its in the mutation function. Anywhere else the console.log is empty. It seems to me that the state is not persisting from the

Advertisement