嗨,我试图弄清楚如何实现新的角度拦截器,并401 unauthorized通过刷新令牌和重试请求来处理错误.这是我一直关注的指南:https://ryanchenkie.com/angular-authentication-using-the-http-client-and-http-interceptors
我成功缓存了失败的请求并可以刷新令牌,但我无法弄清楚如何重新发送以前失败的请求.我也想让这个与我目前使用的解析器一起工作.
token.interceptor.ts
return next.handle( request ).do(( event: HttpEvent<any> ) => {
        if ( event instanceof HttpResponse ) {
            // do stuff with response if you want
        }
    }, ( err: any ) => {
        if ( err instanceof HttpErrorResponse ) {
            if ( err.status === 401 ) {
                console.log( err );
                this.auth.collectFailedRequest( request );
                this.auth.refreshToken().subscribe( resp => {
                    if ( !resp ) {
                        console.log( "Invalid" );
                    } else {
                        this.auth.retryFailedRequests();
                    }
                } ); …我正在使用HttpAngular HttpClient的解决方案,但是我决定进行迁移并使用新的解决方案,并且我试图创建一种解决方案Interceptors来管理需要刷新令牌以及需要将标头修改为放置授权令牌。