import { Injectable, OnInit } from '@angular/core';
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { environment } from '../../../environments/environment';

@Injectable({
  providedIn: 'root'
})
export class UserService  {

  private apiURL = environment.apiURL;
  constructor(private http: HttpClient) {
   }

  getUser(username:string) {
    const url = `${this.apiURL}/users`;
    const headers = new HttpHeaders({
      'Content-Type': 'application/json',
      Authorization: 'Bearer ' + localStorage.getItem('auth_token'),
    });
    const params = { name : username };

    return this.http.get<any[]>(url,{ headers:headers, params:params })
  }


}