Skip to content
This repository was archived by the owner on Feb 26, 2024. It is now read-only.
This repository was archived by the owner on Feb 26, 2024. It is now read-only.

HttpClientInMemoryWebApiModule has http-backend.service dependency #215

Open
@pauleustice

Description

@pauleustice

Hi, I've just tried using this module for the first time and ran into this issue:

Version: 0.6.1
Angular Version: 6

When trying to build, I receive this Typescript error, failing the build:

ERROR in node_modules/angular-in-memory-web-api/http-backend.service.d.ts(2,75): error TS2307: Cannot find module '@angular/http'

App module (cut down for brevity):

import { HttpClientInMemoryWebApiModule } from 'angular-in-memory-web-api';
import { MockApiService } from './services/mock-api.service';

@NgModule({
  declarations: [ AppComponent ],
  imports: [
    BrowserModule,
    HttpClientModule,
    environment.production ?
      [] : HttpClientInMemoryWebApiModule.forRoot(
      MockApiService, {
        dataEncapsulation: false,
        passThruUnknownUrl: false,
        put204: false // return entity after PUT/update
      }
    ),
  ]

MockApiService:

import { InMemoryDbService } from 'angular-in-memory-web-api';

export class MockApiService implements InMemoryDbService {
  createDb() {
    const reports = [
      { id: 1, limit: 37},
      { id: 2, limit: 118 },
      { id: 3, limit: 93 },
    ];
    return {
      reports
    };
  }
}

As far as I can tell, if one is using the HttpClientInMemoryWebApiModule, there should be no dependencies on @angular/http. It's a simple fix to npm i it, but seems like a bug nonetheless.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions