'How to cancel first, outdate request if second was alraedy sent

I need to cancel first pending request if another was sent from the same service as the first is outdated already and there is no need to spend time on it as there will be two parallel request from same service.

Could you tell me ways how to do it?

It's GET request from service with @service decorator like:

this.service.get({ id: someId }).then(this.result)


Solution 1:[1]

You can't cancel a request from the client's side, once its fired. You can cancel it from the server's side, once a new request arrives - and identify the duplicate using some key in the request headers or body. The only thing you can do on the client's side - is ignore the response of the first request.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 S Shahar