I am enjoying the Tour of Heroes tutorial. Everything is working as it should but I'm really puzzled abou the http adding a hero functionality. It seems to magically know what id to assign to the new hero. I don't see any code anywhere that gets the max id of existing heroes anmd increments 1. Can someone explain?
Asked
Active
Viewed 54 times
0
-
The backend code does that. Not the frontend code. – JB Nizet Mar 05 '17 at 11:55
-
https://github.com/angular/in-memory-web-api this is what it uses to mock a backend server – Paul Samsotha Mar 05 '17 at 12:39
-
There is no backend code in this tutorial. The web api is mocked in the front end., So my question still stands, how does it know about incrementing the id property? – Nissim Levy Mar 05 '17 at 20:37
1 Answers
0
It's a part of the 'in-memory-web-api' that is called as a mockup sercice. apparenly, it creates an id in case no id is passed. https://github.com/angular/in-memory-web-api#custom-genid

Shai Kimchi
- 746
- 1
- 4
- 22