1
votes

Just started learning angular development. Following official angular doc from angular.io. Everything was working fine step by step till I reach https://angular.io/tutorial/toh-pt6

Added HttpClientInMemoryWebApiModule for mocking remote server, now it's not working.

here is browser console logs: enter image description here

It's now able to find out 'api/heroes' endpoint. this may be configuration issue with 'HttpClientInMemoryWebApiModule'.

Here is my source code: https://github.com/csankhala/angular-tour-of-heroes

Please let me know what I missed?

1
try to change HEROES to heroes inside your in-memory-data.service - Gérôme Grignon
oh my god. it works. Thanks a lot. but i didn't understand, it is just a local variable. how it is mapped to endpoint url? - c.sankhala
it's the way the in memory module map your data to url so you don't have to configure it yourself as its goal is to help you to prototype quickly (not production friendly) - Gérôme Grignon
Thanks. As your solution works, you can post it as answer. - c.sankhala

1 Answers

2
votes

Your urls must matchs the name of your data declared inside the in-memory-data.service.

In this situation, in order to query api/heroes, the createDb() function returned object must include a variable named heroes (rather than HEROES).