Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR TYPESCRIPT

HeroService: getHeroes failed: Http failure response for http://localhost:4200/api/heroes: 404 Not Found

//One of the solution can be to order the modules import
imports: [
    BrowserModule,
    FormsModule,
    HttpModule,
    InMemoryWebApiModule.forRoot(InMemoryDataService),
    AppRoutingModule
],

//Second can be to make sure in your in-memory-data.service.ts file,
//that the const HEROES is in minuscule : heroes
const heroes: Hero[]=[
      {id:11, name:"Dr 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'},
    ];
Source by github.com #
 
PREVIOUS NEXT
Tagged: #getHeroes #Http #failure #response #Not #Found
ADD COMMENT
Topic
Name
4+3 =