I recently developed a service in Angular called UserService, along with a function in app.componenet.ts that calls upon it. Let's take a look at the code inside the UserServer:
// Login function within the UserService - takes user's ID and returns their 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 here's how the function is implemented in the app.component.ts file:
Login()
{
this.userService.Login(this.userID).subscribe(name =>{
alert('Your name is' + name)
});
}
The issue I'm facing is that the Login function within the component isn't entering the subscribe function. It reaches the Login function in the Service but does not proceed to the subscribe method. What could be causing this problem?
I've tried debugging the code, but couldn't spot anything unusual.