src/app/Services/auth.service.ts
Methods |
constructor(http: HttpClient)
|
||||||
Defined in src/app/Services/auth.service.ts:13
|
||||||
Parameters :
|
login |
login(email: string, password: string)
|
Defined in src/app/Services/auth.service.ts:21
|
Returns :
Observable<any>
Observable |
register |
register(email: string, username: string, password: string)
|
Defined in src/app/Services/auth.service.ts:34
|
Returns :
Observable<any>
Observable |
import { Injectable } from '@angular/core';
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { Observable } from 'rxjs';
const AUTH_API = 'https://gruppe1.testsites.info/api/user';
const httpOptions = {
headers: new HttpHeaders({ 'Content-Type': 'application/json' }),
};
@Injectable({
providedIn: 'root',
})
export class AuthService {
constructor(private http: HttpClient) {}
/**
* @param {string} email
* @param {string} password
* @returns Observable
*/
login(email: string, password: string): Observable<any> {
return this.http.post(AUTH_API + '/login', {
email,
password,
});
}
/**
* @param {string} email
* @param {string} username
* @param {string} password
* @returns Observable
*/
register(email: string, username: string, password: string): Observable<any> {
return this.http.post(
AUTH_API + '/register',
{
email,
password,
username,
},
httpOptions
);
}
}