import { Injectable } from '@angular/core'; import { HttpClient } from '@angular/common/http'; @Injectable({ providedIn: 'root' }) export class QueryService { constructor(private http: HttpClient) { } query(url: string, method: string, params?:any) { switch(method){ case 'GET': return this.http.get(url, params); break; case 'POST': return this.http.post(url, params); break } return null; } }