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.
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
you can set passThruUnknownUrl to forward to real backend for un-matching endpoints
e.g.,
InMemoryWebApiModule.forRoot(InMemoryDataService, {
passThruUnknownUrl: true
}),
Method 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
Method 3
in app.module.ts
import { HttpClientInMemoryWebApiModule } from 'angular-in-memory-web-api';
import { InMemoryDataService } from './my-module/services/in-memory-data.service';
in app.module.ts imports array
HttpClientInMemoryWebApiModule.forRoot(InMemoryDataService, { dataEncapsulation: false, passThruUnknownUrl: true })
passThruUnknownUrl related doc
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0