E
E
Enickckey2022-03-05 10:47:08
Vue.js
Enickckey, 2022-03-05 10:47:08

How to achieve asynchrony from getter?

Hello.
I have a problem.
There is an action in which I make a request.

api.getList().then((res) =>  {
      state.Forms = res.data 
      commit("createStructure");
  });


In the mutation, I actually change the state.
There is a getter for this property.

The problem is that when in the component I access the getter.
computed: {
    ...mapGetters(["actualForms"]),
  },

First, it is processed (empty) and then the response comes from the server.
I tried to do both in created and mounted. The result is one

. How to make it to first wait for information from the back, and then draw it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Anton, 2022-03-05
@Fragster

why is this not action? well, or let the getter return an asynchronous function.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question