W
W
Woodwalker2020-08-31 11:01:46
JavaScript
Woodwalker, 2020-08-31 11:01:46

How to make a sequence of queries in input?

The situation is this.
There is an input, data is entered into it, a request is made based on this data. The problem is that the requests are not executed sequentially. For example. We entered 223, 3 requests are made (2,22,223) and the last conditionally 2 request comes in, because the answers have different weights, and from 22 it is the heaviest.
Schematically, I did this.

const loadData = async (value) => {
const response = await fetch(url+value)
}

// функция которая срабатывает когда мы вводим что-то в input
const onChange = async (value) => {
await loadData(value)
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Evgeny Shcherbakov, 2020-08-31
@Woodwalker

Do you need to make all queries or only with the last value?
If with the latter, then use debounce.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question