cost 192 ms
Angular14 服務 CORS 和身份驗證 Header

[英]Angular14 Service CORS and Authentication Header

我有一個 Angular 14 應用程序,我剛剛開始使用授權標頭在不同的域中調用 webapi (c#),所以 CORS 正在打擊我。 我想不通的是如何讓它接受授權 header 並讓一切仍然命中 CORS。 我的測試服務很簡單: 我正在使用 HttpInterceptor: 攔截(請求:Http ...

在 Angular 中使用 MSAL 服務登錄的 LoaderService 問題

[英]LoaderService issue using MSAL Service for login in Angular

我正在開發一個需要 MS 憑據才能登錄的 Angular 應用程序。此外,我正在使用 Http 攔截器在使用任何 HttpClient 的調用時顯示加載程序組件。 我的問題是當我登錄到我的應用程序時,使 MSALService 庫的調用不顯示加載程序,並且我的應用程序似乎被凍結,直到 MSAL 配置 ...

在 Angular HTTP 攔截器中對攔截 function 進行單元測試

[英]Unit testing the intercept function in an Angular HTTP interceptor

我寫了一個 Angular 9 HTTP 攔截器,我想在相對隔離的情況下對攔截器 function 進行單元測試。 從我已經在StackOverflow上看到的情況來看,人們建議制作假的 HTTP 請求或返回一個基本請求,這對我不起作用,因為我使用了 .pipe 方法( TypeError: nex ...

攔截器沒有攔截,盡管只有一個 HttpClientModule

[英]Interceptor not intercepting, despite only one HttpClientModule

我在 Angular 中有應用程序,但只有一個 HttpClientModule,但是當我在構造函數中提供 HttpClient 時,如下所示: 但在另一個模塊中我也有類似的構造函數 我的 app.module 表格模塊內容 主應用模塊 我究竟做錯了什么? ...

實施CanDeactivate Guard時出錯

[英]Error while implementing CanDeactivate Guard

我目前正在嘗試為我的角度應用程序實現CanDeactivate Guard,該應用程序已經具有HTTP攔截器來解析身份驗證。 但是添加CanDeactivate防護會引發錯誤,如下所述。 我已經在AppModule的providers數組中注冊了實現CanDeactivate接口的Cla ...

Angular - 有沒有辦法推遲服務實例化,直到應用程序被異步初始化?

[英]Angular - Is there a way to defer service instantiation until app is asynchronously initialized?

我有一個帶有HTTP攔截器的Angular 5應用程序,每當攔截請求時都會調用另一個服務。 我想使用配置文件使服務可配置,因此我嘗試使用在應用程序初始化期間異步加載配置的服務(使用APP_INITIALIZER掛鈎)。 問題是,在配置服務從配置文件加載配置之前,我要使用的服務是實例化的。 ...

無法將路由器注入 HttpInterceptor (Angular 7)

[英]Can't inject Router into HttpInterceptor (Angular 7)

我想將 Angular Router 注入到我的 HttpInterceptor 中。 不幸的是,在瀏覽器控制台中拋出以下錯誤: 類型錯誤:this.router 未定義我像往常一樣將它添加到我的構造函數中: 此外,我在 app.module.ts 中的 providers 數組中執行了以下操作: ...

HttpClient攔截器重試單元測試(預計沒有打開請求,找到1)

[英]HttpClient interceptor retry unit testing (Expected no open requests, found 1)

我有一個簡單的HttpClient攔截器,只是重試失敗的請求一定次數。 現在,我正在嘗試為它編寫單元測試,但不知怎的,我最終得到了一個未完成的請求。 我已經嘗試在fakeAsync包裝測試或使用done但它似乎沒有幫助。 現在我沒有想法。 我得到的錯誤是: Error: Expect ...

模擬服務器響應,即使服務器無法訪問

[英]mock the server response even the server is unreachable

我知道的事情( 如果我錯了,請糾正我,謝謝:) ): HttpInterceptor工作方式類似於面向方面的編程 ; 可以為請求添加/修改httpOptions ; 用clone()修改響應也可以實現響應; 我的問題 我想測試一些庫,而它們的相關服務器有時 ...

可以在HttpInterceptor中獲取上傳進度事件,但不能從HttpClient調用中獲取嗎?

[英]Can get upload progress event in HttpInterceptor but not from HttpClient call?

我正在使用HttpInterceptor並且我有一個Http服務,該服務調用運行HttpClient的http方法。 我正在嘗試獲取上傳進度,並且在這里面臨兩個問題, 首先,進度事件僅被HttpInterceptor捕獲,而不是服務中的任何Http調用者方法。 看起來前者掩蓋了進度報告 ...

Angular 5-在HttpInterceptor中操作HttpErrorResponse的error屬性

[英]Angular 5 - Manipulating HttpErrorResponse's error property in HttpInterceptor

我有來自rest api的自定義錯誤消息主體,如JSON。 我想將其作為對象的訂閱的錯誤范圍。 我嘗試使用HttpInterceptor在每次響應后將其轉換為對象。 但是HttpErrorResponse是只讀的。 如何在服務中獲取該對象? ...

在Angular HttpClient攔截器中使用promise

[英]Use a promise in Angular HttpClient Interceptor

我可以在HttpInterceptor使用promise嗎? 例如: 為什么我需要這個? 因為我需要在向服務器發出請求之前獲取一個令牌以添加到請求標頭。 我的攔截器: 請求: 我面臨的問題: - >我在承諾解決之前得到了這個錯誤。 承諾re ...


 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM