Closed ejavier2018 closed 6 years ago
I found that I've missed the {} in InMemoryDataService. :(
It worked after I changed return heroes;
to return {heroes};
export class InMemoryDataService implements InMemoryDbService{
createDb(){
let heroes: Hero[] = [
{ id: 11, name: 'Mr. Nice' },
{ id: 12, name: 'Narco' },
{ id: 13, name: 'Bombasto' },
{ id: 14, name: 'Celeritas' },
{ id: 15, name: 'Magneta' },
{ id: 16, name: 'RubberMan' },
{ id: 17, name: 'Dynama' },
{ id: 18, name: 'Dr IQ' },
{ id: 19, name: 'Magma' },
{ id: 20, name: 'Tornado' }
];
return heroes; <<---- this should be return {heroes};
}
I am stuck at HTTP > Get heroes with HttpClient section of the tutorial This section doesn't seem to be able to retrieve Hero list from my InMemoryDataService.
The list doesn't display in the browser and when I inspect elements from browser to see error, I see this error:
I have followed the sequence of importing the HttpClientModule first before HttpHttpClientInMemoryWebApiModule in NgModule but I still get same error. I wonder if anyone is able to tell what I've missed.
I have uploaded my code to this repository: https://github.com/ejavier2018/angular-tour-of-heroes.git
Thanks! Edward