import { Injectable } from "@angular/core"; import { Api } from "./api"; import { Observable } from "rxjs"; import { Discount, IRslt } from "../../public-api"; @Injectable({ providedIn: 'root' }) export class DiscountService{ get route(){ return this.api.base + 'discount/' } 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(discount: Discount): Observable> { return this.api.post>(this.route, discount) } put(discount: Discount): Observable> { return this.api.put>(this.route, discount) } delete(discount: Discount): Observable> { return this.api.delete>(this.route + '/' + discount._id) } }