import { Injectable } from "@angular/core"; import { Api } from "./api"; import { Observable } from "rxjs"; import { IRslt, Invoice } from "../../public-api"; @Injectable({ providedIn: 'root' }) export class InvoiceService{ get route(){ return this.api.base + 'invoice/' } constructor(private api:Api){} setToken(token:string){ this.api.token = token; } //return subscriber for all.... get(): Observable> { return this.api.get>(this.route + 'token') } getByID(id: string): Observable> { return this.api.get>(this.route + '/' + id) } post(invoice: Invoice): Observable> { return this.api.post(this.route, invoice) } put(invoice: Invoice): Observable> { return this.api.put(this.route, invoice) } delete(invoice: Invoice): Observable> { return this.api.delete(this.route + '/' + invoice._id) } }