| 1234567891011121314151617 |
- import { HttpClient, HttpErrorResponse, HttpHeaders } from '@angular/common/http';
- import { Injectable } from '@angular/core';
- import { Observable, throwError } from 'rxjs';
- import { catchError, tap } from 'rxjs/operators';
- @Injectable({ providedIn: 'root' })
- export class AuthService {
- private loginUrl = 'http://localhost:8080/login'; // Replace with your server login URL
- constructor(private http: HttpClient) { }
- login(username: string, password: string) {
- const headers = new HttpHeaders({ Authorization: 'Basic ' + btoa(username + ':' + password) });
- console.log("logged in service");
- return this.http.post(this.loginUrl, {}, { headers });
- }
- }
|