0.0.1 • Published 6 years ago

nmk-rest v0.0.1

Weekly downloads
1
License
MIT
Repository
-
Last release
6 years ago

NMK-REST Library

An angular 5+ base library service to perform basic http-request. It is a wrapper for HttpClient.

Getting started

Installation steps

To install simply run this command on your project's root:

npm install --save rest

Setup

  • Go to your AppModule file
  • import RestModule and include it on the module imports (Not mandatory)
...
import { RestModule } from 'rest';
...

@NgModule({
    ...
    imports: [
        ...
        RestModule,
        ...
    ]
    ...
})
export class AppModule {}
  • Now you can extend the RestService from any service. Example:
import { Injectable } from '@angular/core';
import { RestService } from 'rest';
import { TodoItem } from './models';
import { HttpClient } from '@angular/common/http';

@Injectable()
export class ExampleService extends RestService<number, TodoItem> {
    constructor(httpClient: HttpClient) {
        super(httpClient, 'https://jsonplaceholder.typicode.com/todos');
    }
}
  • And of course in any component you can inject in your constructor:
    constructor(private readonly _exampleService: ExampleService) {

    }