angular / in-memory-web-api

The code for this project has moved to the angular/angular repo. This repo is now archived.
MIT License
1.18k stars 231 forks source link

If defined at app.module, feature module doesn't work #202

Open bhaidar opened 6 years ago

bhaidar commented 6 years ago

Hi, I have this module defined at the app.module. My service calls to the server are placed in a feature module that is lazily loaded. For some reason, im getting always that the url http://localhost:4200/api/documents is not found 404

I've defined the in-memory service to return "{ documents }"

"Http failure response for http://localhost:4200/api/documents: 404 Not Found"

I also made sure I am using the following version as I am using Angular 5.X "angular-in-memory-web-api": "0.5.4",

Any idea?

kenmlee commented 6 years ago

One possible mistake is the order of HttpClientModule.

Check if you have imported HttpClientModule both in App.module and feature module.

The HttpClientModule must be import before HttpClientInMemoryWebApiModule. If you have imported HttpClientModule again in your feature module, HttpClientInMemoryWebApiModule will not work in your feature module.