How to cancel a HTTPRequest in Angular 2?

Discussão em 'Angular' iniciado por tom10271, Janeiro 6, 2025.

  1. tom10271

    tom10271 Guest

    How to cancel a HTTPRequest in Angular 2?

    I know how to reject the request promise only.

    return new Promise((resolve, reject) => {
    this.currentLoading.set(url, {resolve, reject});

    this.http.get(url, {headers: reqHeaders})
    .subscribe(
    (res) => {
    res = res.json();

    this.currentLoading.delete(url);
    this.cache.set(url, res);

    resolve(res);
    }
    );
    });

    Continue reading...

Compartilhe esta Página