98. Login service call (#12)

This commit is contained in:
Art
2021-09-12 11:33:40 +03:00
parent 92ecc595f0
commit fa5c69952c
4 changed files with 26 additions and 1 deletions

View File

@ -1,9 +1,22 @@
import {Injectable} from '@angular/core';
import {environment} from "../../environments/environment";
import {HttpClient, HttpErrorResponse, HttpResponse} from "@angular/common/http";
import {UserLogin} from "../dto/user-login";
import {Observable} from "rxjs";
@Injectable({
providedIn: 'root'
})
export class AuthenticationService {
constructor() { }
private host: string = environment.apiUrl;
constructor(private httpClient: HttpClient) {
}
public login(userDto: UserLogin): Observable<HttpResponse<any> | HttpErrorResponse> {
return this.httpClient.post<HttpResponse<any> | HttpErrorResponse>(`${this.host}/user/login`, userDto, {observe: 'response'});
}
}