R
R
Roman2019-03-25 11:16:05
Vue.js
Roman, 2019-03-25 11:16:05

How to cancel all requests in axios except the last one?

Good afternoon. There is a vue component for autocompletion. On each click, a query string is sent to the server. Accordingly, a situation arises when there are many requests to the server at the same time, although, in fact, only the last one is needed. How can this be implemented?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Alexey Yarkov, 2019-03-25
@roman94

You need a debounce

N
nvdfxx, 2019-03-25
@nvdfxx

call the method not by keyup or similar events, but by submit, for example

I
Ilya Zabcode, 2019-03-25
@zabozlaev

debounce in the lodash package will help you :) https://lodash.com/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question