How to get responses from requests in the same order in which requests were made? At the same time more requests may come

  ajax, api, javascript, reactjs, request

I have a search navbar where users can type some word and it will show the result. On each typed character, it makes API call and returns data.

For example:
User types – "amazon". It makes 6 API calls(on each character) and the result of the last call ("amazon") I need to display. THE PROBLEM is that I can’t know which response was the last one, when the user was typing "ama" it’s a 3rd call, the result can come as last and it will not correct.

So I need somehow to get responses in order.

One more time, EXAMPLE:
User types:
"a" - API CALL - response(data with letter "a")
"am" - API CALL - response(data with letters "am")
"ama" - API CALL - ...
"amaz" - API CALL - ...
"amazo" - API CALL - ...
"amazon" - API CALL - ...

Can happen that for example "amazo" or "a" response can be the last and the result will be incorrect.

Source: Ask Javascript Questions