Having an issue with my login code in TypeScript. The 'subscribe' function is deprecated and I'm not sure how to proceed. Can anyone provide some guidance?
doLogin()
{
this.userService.doLogin(this.loginForm.value).subscribe(
result =>
{
console.log(result);
localStorage.setItem('userData', JSON.stringify(result));
this.router.navigate(['/list-user']);
this.toastr.success('Success', 'Logged In Successfully');
},
(error) =>
{
console.log(error);
this.toastr.error('Failed', 'Invalid Credentials');
});
}
This code worked fine in another project, but now I am encountering a deprecation warning:
@deprecated — Instead of passing separate callback arguments, use an observer argument. Signatures taking separate callback arguments will be removed in v8. Details: https://rxjs.dev/deprecations/subscribe-arguments
'(next?: ((value: Object) => void) | null | undefined, error?: ((error: any) => void) | null | undefined, complete?: (() => void) | null | undefined): Subscription' is deprecated.ts(6385) Observable.d.ts(55, 9): The declaration was marked as deprecated here.