1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

Set timeout in a http.post call using typescript

Discussão em 'Angular' iniciado por Vinicius Martin, Setembro 27, 2024.

  1. I created one API call which is working fine with the following code:


    timeoutTime : number = 10000;

    this.http.post(this.apiUrl+'/login', JSON.stringify(data), {
    headers: new HttpHeaders().set('Content-Type', 'application/json').set('language', this.translate.getDefaultLang()),
    }).pipe(timeout(this.timeoutTime))
    .subscribe(res => {
    resolve(res);
    }, (err) => {
    if (err.status == 408 || err.status == 0 || err.status == 503 || err.name == 'TimeoutError'){
    reject(this.getTimeoutResponse());
    } else {
    }
    });
    });
    }


    The issue is:

    That part it not working

    .pipe(timeout(this.timeoutTime))


    The timeout is not being set. This is an angular app using Ionic and the default timeout is close to 5 seconds, I am trying to change it to 10.

    Thanks

    Continue reading...

Compartilhe esta Página