DEV Community

Siddharth Shankar
Siddharth Shankar

Posted on

Getting Undefined

Hi All,
I am calling a service method with return type as User.
I am getting undefined , Please help
component code :
this.user = this._authService.login(this.email, this.password)
//this.user is comming undefined

Service Code :
login(email : string , password : string): User {

  this.checkLogin(email, password).subscribe((data)=>{
  //console.log(data);
  this.usr = data;
  console.log(this.usr.name);
  if(this.usr != null)
  {
   return this.usr;
  }
Enter fullscreen mode Exit fullscreen mode

})

Top comments (0)