Hello there, I am currently facing an issue with setting up an authentication service. Whenever I try to login, I keep getting this error message:
Type 'Observable' is not assignable to type 'Observable<HttpResponse>'. Type 'ArrayBuffer' is missing the following properties from type 'HttpResponse': body, type, clone, headers, and 4 more.
The login function in question looks like this:
login(user:User): Observable<HttpResponse<User>>{
return this.http.post<User>(`${this.apiUrl}/login`, user, {observe: Response});
}
Here is the User model interface:
export interface User {
username: string;
password:string;
}
I am calling this function within my login component:
onLogin(user: User):void{
this.subs.add(
this.authService.login(user).subscribe(
(response) =>{
this.authService.addTokenToCache(response.headers.get('Jwt-Token') || '{}');
// this.authService.addUserToCache(response.body|| '{}');
this.router.navigateByUrl("/home");
this.showLoading=false;
},
(error: HttpErrorResponse)=>{
alert(error.message);
this.showLoading=false;
}
))
}
Can someone please guide me on how to resolve this issue?