question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

InMemoryWebApiModule does not work.

See original GitHub issue

npm install --save angular2-in-memory-web-api then do like the tutorial

step 1 add in-memory-data.service.ts //in-memory-data.service.ts

import {InMemoryDbService} from "angular2-in-memory-web-api/index";
export class InMemoryDataService implements InMemoryDbService {
  createDb() {
    let heroes = [
      {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};
  }
}

step2 update AppModule //app.module.ts

import {BrowserModule, Title} from "@angular/platform-browser";
import {NgModule} from "@angular/core";
import {FormsModule} from "@angular/forms";
import {HttpModule} from "@angular/http";
import {AppComponent} from "./app.component";
import {AppRoutingModule} from "./app-routing.module";
import {PageNotFoundComponent} from "./common/page-not-found/page-not-found.component";
import {InMemoryWebApiModule} from "angular2-in-memory-web-api/index";
import {InMemoryDataService} from "./memory-data/in-memory-data.service";

@NgModule({
  declarations: [
    AppComponent,
    PageNotFoundComponent
  ],
  imports: [
    BrowserModule,
    FormsModule,
    HttpModule,
    InMemoryWebApiModule.forRoot(InMemoryDataService),
    AppRoutingModule
  ],
  providers: [
    Title
  ],
  bootstrap: [AppComponent]
})
export class AppModule { }

After done the steps above,I just run start script in package.json(ng serve) Output an error:

ERROR in Error encountered resolving symbol values statically. Calling function ‘InMemoryWebApiModule’, function calls are not supported. Consider replacing the function or lambda with a reference to an exported function, resolving symbol AppModule in D:/angular2/cli-demo/src/app/app.module.ts, resolving symbol AppModule in D:/angular2/cli-demo/src/app/app.module.ts

What’s wrong?How could I make it works?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:3
  • Comments:20 (1 by maintainers)

github_iconTop GitHub Comments

38reactions
SMAK1993commented, Mar 24, 2018

Faced version compatibility issues:

npm install angular-in-memory-web-api --save
npm WARN angular-in-memory-web-api@0.6.0 requires a peer of @angular/common@^6.0.0-rc.0 but none is installed. You must install peer dependencies yourself.
npm WARN angular-in-memory-web-api@0.6.0 requires a peer of @angular/core@^6.0.0-rc.0 but none is installed. You must install peer dependencies yourself.
npm WARN angular-in-memory-web-api@0.6.0 requires a peer of @angular/http@^6.0.0-rc.0 but none is installed. You must install peer dependencies yourself.
npm WARN angular-in-memory-web-api@0.6.0 requires a peer of rxjs@^6.0.0-beta.1 but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.1.3 (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

+ angular-in-memory-web-api@0.6.0
added 1 package in 6.927s

According to changelog: https://github.com/angular/in-memory-web-api/blob/master/CHANGELOG.md Version 0.6.0 has breaking changes and is probably only compatible with Angular 6 (not LTS yet).

Made it work by downgrading to angular-in-memory-web-api@0.5.4.

npm install angular-in-memory-web-api@0.5.4 --save

8reactions
ddwolfcommented, Feb 2, 2018

encountered the same problem, with angular-in-memory-web-api: 0.5.3 @angular/cli 1.6.7

Read more comments on GitHub >

github_iconTop Results From Across the Web

angular-in-memory-web-api not responding - Stack Overflow
No run time error in the js console. Nothing is happening. Like if there was no response from the "api server". I even...
Read more >
How to use the angular-in-memory-web-api/in-memory ... - Snyk
Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues...
Read more >
Angular 15 In-memory Web API tutorial: Mocking CRUD APIs ...
This is really handy for Angular developers who are working on a front-end application but do not yet have a back-end in place....
Read more >
Angular In-memory Web API tutorial: Mocking CRUD APIs in ...
A tutorial of Angular's in-memory-web-api to make a simple CRUD server, and to create a functional frontend without backend assistance.
Read more >
angular-in-memory-web-api - npm
If an existing, running remote server should handle requests for collections that are not in the in-memory database, set Config.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found