From 83423751aa5dd0be6640486272b8924fdf1ff348 Mon Sep 17 00:00:00 2001 From: Alix JEUDI--LEMOINE Date: Fri, 17 Jan 2025 15:05:06 +0100 Subject: [PATCH] Fix login service HTTP request type --- src/app/services/login.service.ts | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/app/services/login.service.ts b/src/app/services/login.service.ts index 26351e4..6b0f0c4 100644 --- a/src/app/services/login.service.ts +++ b/src/app/services/login.service.ts @@ -1,4 +1,4 @@ -import { HttpClient, HttpHeaders } from '@angular/common/http'; +import { HttpClient, HttpParams } from '@angular/common/http'; import { Injectable } from '@angular/core'; import { Observable } from 'rxjs'; import { environment } from '../../environments/environment'; @@ -11,13 +11,11 @@ export class LoginService { constructor(private http: HttpClient) {} - login(username: string, password: string): any { - const headers= new HttpHeaders({ - 'Content-Type':'application/x-www-form-urlencoded' - }) - return this.http.post(this.apiUrl + '/login', { - username: username, - password: password, - }, {headers}).subscribe(); + login(username: string, password: string): Observable { + const payload = new HttpParams() + .set('username', username) + .set('password', password); + + return this.http.post(this.apiUrl + '/login', payload); } }