| 1234567891011121314151617181920212223242526272829303132333435 |
- import { Injectable } from '@angular/core';
- import { HttpClient, HttpHeaders } from '@angular/common/http';
- import { map, Observable } from 'rxjs';
- @Injectable({
- providedIn: 'root'
- })
- export class GenericService {
- private _url:string = "http://192.168.100.154:8000/api/generic/";
- private _token:string = 'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJFZERTQSJ9.eyJpc3MiOiJqb3NlLmJAaXR0ZWMubXgiLCJhdWQiOiJkb21pbmlvLnN5cC5teCIsImlhdCI6MTY0NzYxMjc0NCwiY2FkIjoxNjQ3Njk5MTQ0fQ.BkpH8BMrx0hExtdU0EsNGxQxcbx_RqvTpGq12DqfbS0IEej5enf6V6q2DbqPsueK_0DMR_CWU9kMMYQCN2jrCg';
- constructor(private http: HttpClient) { }
- public getDataTable(data: any){
- return this.getQuery(`consulta-tabla/${data}`).pipe(map((data: any) => data));
- }
- private getQuery(query: string){
- const URL = `${this._url}${query}`;
- return this.http.get(URL, {
- headers: new HttpHeaders({
- Authorization: this._token
- })
- });
- }
- private postQuery(query: string, body: any){
- const URL = `${this._url}${query}`;
- return this.http.post(URL, body, {
- headers: new HttpHeaders({
- Authorization: this._token
- })
- });
- }
- }
|