Andre Lopes
Sep 16, 2024

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();

}

```

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

Written by Andre Lopes

Full-stack developer @ Tesla | Public Speaker | AWS | Terraform | Serverless | Gamer | Eternal Geek 🤓

No responses yet

Write a response