iT邦幫忙

1

Angular HttpInterceptor 攔截不到呼叫 firebase cloud functions的request

小弟想請教一個問題,我用Angular呼叫 AngularFireFunctions httpsCallable拿到的functions api,我想用angular HttpInterceptor控制loading畫面的切換,想請問我的request打不到Interceptor裡面,沒有console出結果,想請問是哪個部分出問題?我也有在providers添加這個service

p.s 我有用HttpClient get去測試,是可以進到Interceptor,console得出結果!

@Injectable()
export class AjaxInterceptorService implements HttpInterceptor {

  constructor(private _common: CommonService) { }

  intercept(
    req: HttpRequest<any>, next: HttpHandler
  ): Observable<HttpEvent<any>> {
    console.log(req);
    return next.handle(req);
  }

}
providers: [{
    provide: HTTP_INTERCEPTORS,
    useClass: AjaxInterceptorService,
    multi: true
  }]
hughc iT邦新手 4 級 ‧ 2021-09-02 13:18:26 檢舉
這個interceptor攔截的是以httpclientmodule所發出的api呼叫,我想應該是,你呼叫cloud function時沒有用到httpclient吧!
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友回答

立即登入回答