tareas.service.ts 697 B

123456789101112131415161718192021222324252627
  1. import { Injectable } from '@angular/core';
  2. import { environments } from '../../../../environments/environments';
  3. import { HttpClient, HttpHeaders } from '@angular/common/http';
  4. @Injectable({
  5. providedIn: 'root'
  6. })
  7. export class TareasService {
  8. private URL: string = environments.baseUrl;
  9. constructor(private http: HttpClient) { }
  10. private getHeaders(): HttpHeaders {
  11. const token = localStorage.getItem('token') || '';
  12. return new HttpHeaders({
  13. 'Content-Type': 'application/json',
  14. 'Authorization': `Bearer ${token}`
  15. });
  16. }
  17. getTareas(idAlumno: string) {
  18. return this.http.get(`${this.URL}/tareas/usuario/${idAlumno}`, { headers: this.getHeaders() });
  19. }
  20. }