With vanilla JavaScript with the Fetch API you can pass an AbortController signal in the options.
```
const controller = new AbortController();
const signal = controller.signal;
const response = await fetch("https://example.com/", { signal });
```
then you can just cancel the request by calling
```
controller.abort();
```
whenever needed
---------
With Angular, you can just unsubscribe from your subscription
```
public sendRequest() {
let subscription = this.http.get('someurl')
.subscribe(
...
);
}
public cancelRequest() {
subscription .unsubscribe();
}
```