Asp.net

我如何繞過特定網址的“angular-in-memory-web-api”

  • April 24, 2022

我正在使用“angular-in-memory-web-api”來模擬我的 REST web api,但是現在我已經開始編寫實際的 web api,我想替換“angular-in-memory-web-api”步驟一步一步。

範例:我已經編寫了以下 asp.net web api /api/values 但是當我使用上面的 api url 發出 http.get() 請求時,angular 嘗試使用“angular-in-memory-web-api”來服務它,但是在這個情況下我想繞過“angular-in-memory-web-api”,以便我的實際 Web api 控制器處理該請求。

對於不匹配的端點,您可以設置passThruUnknownUrl轉發到真實後端

例如,

InMemoryWebApiModule.forRoot(InMemoryDataService, {
 passThruUnknownUrl: true
}),

您可以嘗試InMemoryWebApiModule.forRoot(InMemoryDataService)從您的 app.module 中刪除。如果您已經這樣做了,那麼顯示一些程式碼會很有幫助。

另外,考慮使用 Postman 來驗證您的新服務

引用自:https://stackoverflow.com/questions/41076251