Skip to content

Commit 9e42af8

Browse files
committed
signup service renamed to usero service
1 parent 5827beb commit 9e42af8

File tree

3 files changed

+43
-21
lines changed

3 files changed

+43
-21
lines changed

frontend/src/app/components/login/signUp.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Component } from '@angular/core';
2-
import { SignUpService } from '../../services/signUp.service';
2+
import { SignUpService } from '../../services/usero.service';
33

44
@Component({
55
selector: 'signup',

frontend/src/app/services/signup.service.ts

Lines changed: 0 additions & 20 deletions
This file was deleted.
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import { Injectable } from '@angular/core';
2+
import { HttpClient } from '@angular/common/http';
3+
import { Usero } from '../models/usero.model';
4+
import { Observable, throwError } from 'rxjs';
5+
import { catchError } from 'rxjs/operators';
6+
7+
const BASE_URL = '/api/users';
8+
9+
@Injectable({ providedIn: 'root' })
10+
export class SignupService {
11+
12+
user?: Usero;
13+
14+
constructor(private http: HttpClient) {}
15+
16+
getUsers(): Observable<Usero[]> {
17+
return this.http.get(BASE_URL).pipe(
18+
//catchError(error => this.handleError(error)) da un error raro
19+
) as Observable<Usero[]>;
20+
}
21+
22+
getUser(id: number | string): Observable<Usero> {
23+
return this.http.get(BASE_URL + id).pipe(
24+
//catchError(error => this.handleError(error))
25+
) as Observable<Usero>;
26+
}
27+
28+
createUser(user: Usero, password: String) {
29+
this.http.post(BASE_URL + '/signup', {username: user, password: password});
30+
}
31+
32+
updateUser(user: Usero) {
33+
this.http.post(BASE_URL + '/updateUser', {});
34+
}
35+
36+
private handleError(error: any) {
37+
console.log("ERROR:");
38+
console.error(error);
39+
return throwError("Server error (" + error.status + "): " + error.text())
40+
}
41+
42+
}

0 commit comments

Comments
 (0)