import { HttpClient, HttpHeaders } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { map } from 'rxjs';

@Injectable({
  providedIn: 'root'
})
export class TokenService {
  private _url = 'https://qasirh.ittec.mx/v1/public/api/';
  jwt = localStorage.getItem('jwt');

  public checkToken(){
    return this.getQuery('check-token').pipe(map((data: any) => data));
  }

  constructor(private http: HttpClient) { }

  private getQuery(query: string){
    const URL = `${this._url}${query}`;
    return this.http.get(URL, {
      headers: new HttpHeaders({
        Authorization: "Bearer "+this.jwt!
      })
    });
  }
}
