{"id":18110,"library":"angular-in-memory-web-api","title":"angular-in-memory-web-api","description":"An in-memory web API for Angular demos and tests, version 0.21.0. This package simulates a REST API backend for prototyping and testing Angular applications without a real server. It intercepts HttpClient requests and responds with mock data. Supported by the Angular team, it follows Angular's release cadence. Different from full mock libraries (e.g., json-server), it integrates directly with Angular's HTTP interceptors and dependency injection, making it seamless for development and testing. Note: It requires Angular 21+ and rxjs 6.5.3+ or 7.4.0+. Types included.","status":"active","version":"0.21.0","language":"javascript","source_language":"en","source_url":"https://github.com/angular/angular","tags":["javascript","typescript"],"install":[{"cmd":"npm install angular-in-memory-web-api","lang":"bash","label":"npm"},{"cmd":"yarn add angular-in-memory-web-api","lang":"bash","label":"yarn"},{"cmd":"pnpm add angular-in-memory-web-api","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency: provides Angular dependency injection and services.","package":"@angular/core","optional":false},{"reason":"Peer dependency: provides HttpClient and other common modules.","package":"@angular/common","optional":false},{"reason":"Peer dependency: required for Observables used by HttpClient.","package":"rxjs","optional":false}],"imports":[{"note":"ESM-only. Cannot use require().","wrong":"const HttpClientInMemoryWebApiModule = require('angular-in-memory-web-api').HttpClientInMemoryWebApiModule;","symbol":"HttpClientInMemoryWebApiModule","correct":"import { HttpClientInMemoryWebApiModule } from 'angular-in-memory-web-api';"},{"note":"Interface to implement for mock data.","wrong":"","symbol":"InMemoryDbService","correct":"import { InMemoryDbService } from 'angular-in-memory-web-api';"},{"note":"For custom request handling.","wrong":"","symbol":"RequestInfo","correct":"import { RequestInfo } from 'angular-in-memory-web-api';"},{"note":"InMemoryWebApiModule is deprecated; use HttpClientInMemoryWebApiModule.","wrong":"import { InMemoryWebApiModule } from 'angular-in-memory-web-api';","symbol":"InMemoryWebApiModule","correct":"import { HttpClientInMemoryWebApiModule } from 'angular-in-memory-web-api';"}],"quickstart":{"code":"import { Injectable } from '@angular/core';\nimport { InMemoryDbService } from 'angular-in-memory-web-api';\n\n@Injectable({ providedIn: 'root' })\nexport class InMemoryDataService implements InMemoryDbService {\n  createDb() {\n    const heroes = [\n      { id: 12, name: 'Dr. Nice' },\n      { id: 13, name: 'Bombasto' },\n      { id: 14, name: 'Celeritas' }\n    ];\n    return { heroes };\n  }\n}\n\n// In AppModule:\nimport { HttpClientModule } from '@angular/common/http';\nimport { HttpClientInMemoryWebApiModule } from 'angular-in-memory-web-api';\nimport { InMemoryDataService } from './in-memory-data.service';\n\n@NgModule({\n  imports: [\n    HttpClientModule,\n    HttpClientInMemoryWebApiModule.forRoot(\n      InMemoryDataService, { delay: 500, dataEncapsulation: false }\n    )\n  ]\n})\nexport class AppModule { }","lang":"typescript","description":"Shows how to create an in-memory database service and register it with the module."},"warnings":[{"fix":"Replace InMemoryWebApiModule with HttpClientInMemoryWebApiModule.","message":"InMemoryWebApiModule has been deprecated since v0.15. Use HttpClientInMemoryWebApiModule instead.","severity":"deprecated","affected_versions":">=0.15"},{"fix":"Upgrade to Angular 21 or use an older version of angular-in-memory-web-api (e.g., 0.20.x).","message":"In v0.21, peer dependencies require Angular 21+. Installation will fail with older Angular versions.","severity":"breaking","affected_versions":">=0.21"},{"fix":"Remove the import in production builds or use environment flags.","message":"Do not use InMemoryWebApiModule in production. It is intended for development and testing only.","severity":"gotcha","affected_versions":">=0.0"},{"fix":"Use Angular environment configuration to conditionally import the module.","message":"The library suppresses actual HTTP requests; your app will not make real API calls. Ensure you only enable it in non-production environments.","severity":"gotcha","affected_versions":">=0.0"},{"fix":"Set dataEncapsulation: false in options if you want raw array responses.","message":"If dataEncapsulation is true (default), the response is wrapped in a 'data' property. Many examples set it to false for simpler responses.","severity":"gotcha","affected_versions":">=0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Run 'npm install angular-in-memory-web-api --save-dev'.","cause":"Package not installed or import path incorrect.","error":"Error: Cannot find module 'angular-in-memory-web-api'"},{"fix":"Implement InMemoryDbService and pass the class to HttpClientInMemoryWebApiModule.forRoot(InMemoryDataService).","cause":"Missing InMemoryDataService class or forgot to pass it to .forRoot().","error":"NullInjectorError: No provider for InMemoryDbService!"},{"fix":"Import HttpClientInMemoryWebApiModule from 'angular-in-memory-web-api'.","cause":"Incorrect import: using deprecated InMemoryWebApiModule or wrong module.","error":"Error: Unexpected value 'HttpClientInMemoryWebApiModule' imported by the module 'AppModule'. Please add a @NgModule annotation."},{"fix":"Ensure the property name in createDb() matches the resource name in your service (e.g., 'heroes' for /api/heroes).","cause":"createDb() returns an object with property name not matching the URL path.","error":"TypeError: Cannot read properties of undefined (reading 'heroes')"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}