I created a service in angular named UserService, and a function in app.componenet.ts that invites it. Here is the code in the UserServer:
//login function in the UserService – gets user's id and returns his name
Login(userId: string):Observable<string>
{
let headers=new Headers({'Content-type':'application/json;charset=utf-8'});
return this.http.get<string>(`${this.url}/login/${userId}`);
}
and this is the function in the app.componenet.ts:
Login()
{
this.userService.Login(this.userID).subscribe(n=>{
alert('your name is'+n)
});
}
The problem is that the Login function in the componenet doesn't enter the subscribe function. It enters the Login function in the Service but not to the subscribe. What should I do?
I followed the code with debugger and didnt see anything strange
headersare unused.nextpart of your subscriber method.