How I can bypass “angular-in-memory-web-api” for a specific url

北战南征 提交于 2019-12-01 15:10:06

问题


I was using "angular-in-memory-web-api" to mock my REST web api, however now I am have started writing the actual web api and I want to replace the "angular-in-memory-web-api" step by step.

Example: I have written following asp.net web api /api/values however when I issue http.get() request using above api url angular tries to serve it using "angular-in-memory-web-api", however in this case I want to bypass "angular-in-memory-web-api" so that request is entertained by my actual web api controller.


回答1:


you can set passThruUnknownUrl to forward to real backend for un-matching endpoints

e.g.,

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



回答2:


You can try by removing InMemoryWebApiModule.forRoot(InMemoryDataService) from your app.module. If you have done so already, showing some code would be helpful.

Also, consider using Postman to verify your new service



来源:https://stackoverflow.com/questions/41076251/how-i-can-bypass-angular-in-memory-web-api-for-a-specific-url

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!