Gajanand Pandey
Gajanand Pandey

Reputation: 21

Angular 4 HTTP Responce Value Get

I am not able to get HTTP data response.

 onSubmit(form: any): void  {

     this.dataResponse = this._userService.userAuthenticate(form);

    **console.log(this.dataResponse);**

    if (this.dataResponse.status == 'Gajanand')

    {

       this._router.navigate(['dashboard', "index",34 , "subjectid", 45]); 

    }
}

enter image description here

Upvotes: 0

Views: 45

Answers (1)

Carsten Ennulat
Carsten Ennulat

Reputation: 155

It looks like userService is returning a promise. Just simple put your if in a fat arrow function and handle that promise correctly

 onSubmit(form: any): void  {

     this._userService.userAuthenticate(form).then(dataResponse => {    
        if (dataResponse.status == 'Gajanand') {
            this._router.navigate(['dashboard', "index",34 , "subjectid", 45]); 
        }       
     });
}

Upvotes: 1

Related Questions