Подписка с указанием устаревших
this.userService.addUser(this.user).subscribe(
(data)=>{
//success
console.log(data);
this._snack.open('Registered Successfully', 'OK', {
duration: 2000,
verticalPosition: 'top',
horizontalPosition: 'center',
panelClass: ['green-snackbar', 'login-snackbar'],
});
},
(error)=>{
//error
console.log(error);
this._snack.open('Something went Wrong', 'OK', {
duration: 2000,
verticalPosition: 'top',
horizontalPosition: 'center',
panelClass: ['red-snackbar','login-snackbar'],
});
}
);
Я не знаю, что именно происходит, но подпишитесь, показывая устаревшее, следующее сообщение
(method) Observable<Object>.subscribe(next?: ((value: Object) => void) | null | undefined, error?: ((error: any) => void) | null | undefined, complete?: (() => void) | null | undefined): Subscription (+2 overloads)
@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.
Кстати, я использую Angular13
1 ответ
Просто измените его на:
this.userService.addUser(this.user).subscribe({
next: (data) => {
console.log(data);
this._snack.open('Registered Successfully', 'OK', {
duration: 2000,
verticalPosition: 'top',
horizontalPosition: 'center',
panelClass: ['green-snackbar', 'login-snackbar'],
});
},
error: (error) => {
console.log(error);
this._snack.open('Something went Wrong', 'OK', {
duration: 2000,
verticalPosition: 'top',
horizontalPosition: 'center',
panelClass: ['red-snackbar','login-snackbar'],
});
}
});