3.0.0 • Published 3 years ago

ngx-api-mock v3.0.0

Weekly downloads
8
License
MIT
Repository
-
Last release
3 years ago

API Mock for Angular

Mock API calls while development, testing or building an example library. Define results based on url pattern and if needed http methods.

Installation

npm install ngx-api-mock --save

Usage

Import NgxApiMockModule into your app's modules:

import { NgxApiMockModule } from 'ngx-api-mock';

@NgModule({
  imports: [
    NgxApiMockModule.forRoot(config)
  ]
})

Configuration

urlParts: string[]

Trigger api mock interceptor for any url wich contain on part of the list.

rules: {pattern: string; response: any; method?: HttpMethod; delay: number;}[]

Matching url based on pattern and if set method to return result.

Examples

@NgModule({
  imports: [
    NgxApiMockModule.forRoot({
      urlParts: ['thorsten-rintelen.de/v1/'],
      rules: [
        {
          pattern: 'users/\\d+',
          response: 'success',
          method: 'POST',
        },
        {
          pattern: 'users/\\d+',
          response: true,
          method: 'DELETE',
          delay: 2000
        },
      ],
    })
  ]
})

Changelog

v3.0.0

  • BREAKING: Update to Angular 12

v2.0.0

  • BREAKING: Update to Angular 11
  • Output request params to console for each request
3.0.0

3 years ago

2.0.0

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago