0

I want to check if the status code=400 in angular so I can fetch a notif

I've tried this -

signUp() {
    let body =
    {
        login: this.username,
        nom: this.nom,
        prenom: this.prenom,
        adress: this.adress,
        email: this.email,
        password: this.password,
        date_naissance: this.datenaissance,
        num_tel: this.numTel,
    }

    this.signappService.newsignup(body).subscribe(
        (res: any) => {
            console.log(res)
            this.sucess = true;
            this.failed = false;
        },
        (err) => {
            console.warn(err)
            if (err.status == 400) {
                this.failed = true;
                this.sucess = false;
            }
        });
}
atiyar
  • 7,762
  • 6
  • 34
  • 75

1 Answers1

-2

Hello after a short research I found this answear: Get status code http.get response angular2 Did you set "{observe: 'response'}" in newsignup from signappService?

  • To my knowledge, you'll only need that if you want to inspect response codes form successful HTTP requests. The catchError-operator (or error-callback of the subscribe method) will return an EventError or HttpErrorResponse. – Anders Apr 10 '21 at 04:36