update new form recipe detail
This commit is contained in:
parent
df20d25a35
commit
e95078307b
8 changed files with 500 additions and 10 deletions
|
|
@ -5,12 +5,14 @@ import {
|
|||
HttpEvent,
|
||||
HttpInterceptor,
|
||||
HttpErrorResponse,
|
||||
HttpStatusCode,
|
||||
} from '@angular/common/http';
|
||||
import { Observable, catchError, retry, throwError } from 'rxjs';
|
||||
import { Observable, catchError, throwError } from 'rxjs';
|
||||
import { Router } from '@angular/router';
|
||||
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class ErrorInterceptor implements HttpInterceptor {
|
||||
constructor() {}
|
||||
constructor(private router: Router) {}
|
||||
|
||||
intercept(
|
||||
request: HttpRequest<unknown>,
|
||||
|
|
@ -19,6 +21,13 @@ export class ErrorInterceptor implements HttpInterceptor {
|
|||
return next.handle(request).pipe(
|
||||
catchError((error) => {
|
||||
if (error instanceof HttpErrorResponse) {
|
||||
if (error.status == HttpStatusCode.Unauthorized) {
|
||||
this.router.navigate(['/login'], {
|
||||
queryParams: {
|
||||
redirectUrl: request.url,
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
return throwError(() => error);
|
||||
})
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ import { HttpClient } from '@angular/common/http';
|
|||
import {
|
||||
BehaviorSubject,
|
||||
Observable,
|
||||
concat,
|
||||
distinctUntilChanged,
|
||||
map,
|
||||
tap,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue