A
A
akubenov2019-02-06 15:19:07
Vue.js
akubenov, 2019-02-06 15:19:07

Request caching on route change in vue js?

When switching from one route to another (submit forms -> list of elements), a request goes to the server, but the old data is not updated. When I reload the page, the list comes updated.
I call it in the component like this:

created () {
    this.$store.dispatch('getTasks')
  },

Perhaps someone has encountered such a problem. I would be grateful for advice)
Thank you!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Klein Maximus, 2019-02-13
@kleinmaximus

Old data comes because it has not yet been updated on the server - the request is asynchronous.
I don’t know how you send a request with a submit, but first you need to wait for a response, and only then go to another route.
Use router hooks .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question