0.0.2 • Published 5 years ago

angular-crud-op v0.0.2

Weekly downloads
6
License
-
Repository
-
Last release
5 years ago

Install the angular-crud-operations package : npm i angular-crud-op

Extend AngularCrudService into one of the service in your app as below:

@Injectable({
providedIn: 'root'
})
export class CrudService extends AngularCrudService {
 parseData(data): any {
  return data;
}
constructor(http: HttpClient) {
  super(http);
}
}

Call CrudService where ever you want to make HTTP request as below:

import {Component, OnInit} from '@angular/core';
import {CrudService} from '../crud.service';

@Component({
  selector: 'app-test',
  templateUrl: './test.component.html',
  styleUrls: ['./test.component.css']
})
export class TestComponent implements OnInit {

constructor(private crudService: CrudService) {
  }
  getData() {
    this.testService.sendGetRequest('https://jsonplaceholder.typicode.com/todos/1').subscribe(res => {
      console.log(res);
    });
  }
  
  //to make POST request
  postData() {
  const body: any = {};
    this.testService.sendPostRequest(''url', body).subscribe(res => {
      console.log(res);
    });
  }
  //Same process for PUT & DELETE.
  }