locked
Angular, in memory HTTP RRS feed

  • Question

  • User791773689 posted

    Hello everybody,

    Is this the correct forum for a question about Angular ?

    I am going through https://angular.io/tutorial/toh-pt6 (the HTTP section of the tutorial) and at a moment they say to introduce this in app.module.ts :

    HttpClientModule,
    
    // The HttpClientInMemoryWebApiModule module intercepts HTTP requests
    // and returns simulated server responses.
    // Remove it when a real server is ready to receive requests.
    HttpClientInMemoryWebApiModule.forRoot(
      InMemoryDataService, { dataEncapsulation: false }
    )

    The tooltip on InMemoryDataService displays me a text, that I have to get through a screen copy, a picture display program, the keyboard and the notepad. This is how I translate it, followed by the original text in French  :

    (TS) The argument of type 'typeof InMemoryDataService' cannot be assigned to the parameter of type 'Type<InMemoryDbService>'
    
    Impossible to assign type 'InMemoryDataService' to type 'InMemoryDbService'.
      The property 'CreateDb' is missing in type 'InMemoryDataService'.
      (alias) class InMemoryDataService
      import InMemoryDataService
    (TS) L'argument de type 'typeof InMemoryDataService' n'est pas attribuable au paramètre de type 'Type<InMemoryDbService>' Impossible d'assigner le type 'InMemoryDataService' au type 'InMemoryDbService'. La propriété 'CreateDb' est manquante dans le type 'InMemoryDataService'.
    
    

    It seems the implementation of in memory HTTP has been modified in a way that two parts are incompatible.

    Any hint about a way to get it run ?

    Monday, February 25, 2019 11:55 AM

All replies

  • User283571144 posted

    Hi Gluups,

    It seems version compatibility issues.

    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).

    I suggest you could firstly run the command to check the angular version you have installed the angular.

    ng version

    If your installed angualr CLI 7, I suggest you could installed the  0.7.0 version.

    Best Regards,

    Brando

    Tuesday, February 26, 2019 6:23 AM
  • User791773689 posted

    OK thank you.

    I presume if I did not put a git repository on this project the best I can do to rollback is to undo each instruction manually.

    It would have been a good idea from them to put download links for the versions in the history.

    185 is an upgrade to rxjs 6, I have rxjs 6.3.3 that seems to be the good one.

    Tuesday, February 26, 2019 8:32 AM
  • User791773689 posted

    Well, I arrive on pages that show differences between branches at the time they were written :

    https://github.com/angular/in-memory-web-api/compare/a54640d42a1f84db94109261918730728c9fe6a6..290ea591f50c77ab720db22ee36186940828ea85

    Shall I have to redo every step ?

    Friday, March 1, 2019 11:00 AM
  • User283571144 posted

    Hi Gluups,

    In my opinion, you just need to use the right in memory web api version.

    Best Regards,

    Brando

    Monday, March 4, 2019 8:59 AM
  • User791773689 posted

    Oh yes, good idea thank you, this is just what I am looking for.

    Monday, March 4, 2019 9:22 AM