118. Custom HTTP response mapping(#13)

This commit is contained in:
Art
2021-09-13 09:05:21 +03:00
parent 03b6be2900
commit 22d922f3a0
2 changed files with 12 additions and 11 deletions

View File

@ -0,0 +1,7 @@
export interface CustomHttpResponse {
timestamp: Date;
httpStatusCode: number;
httpStatus: string;
reason: string;
message: string;
}

View File

@ -32,9 +32,9 @@ export class UserService {
.put<User | HttpErrorResponse>(`${this.host}/user/${currentUsername}`, formData); .put<User | HttpErrorResponse>(`${this.host}/user/${currentUsername}`, formData);
} }
public resetPassword(email: string): Observable<HttpResponse> { public resetPassword(email: string): Observable<CustomHttpResponse> {
return this.httpClient return this.httpClient
.post<HttpResponse>(`${this.host}/user/resetPassword/${email}`, null); .post<CustomHttpResponse>(`${this.host}/user/resetPassword/${email}`, null);
} }
public updateProfileImage(username: string, formData: FormData): Observable<HttpEvent<User | HttpErrorResponse>> { public updateProfileImage(username: string, formData: FormData): Observable<HttpEvent<User | HttpErrorResponse>> {
@ -46,9 +46,9 @@ export class UserService {
}); });
} }
public deleteUser(userId: string): Observable<HttpResponse | HttpErrorResponse> { public deleteUser(userId: string): Observable<CustomHttpResponse | HttpErrorResponse> {
return this.httpClient return this.httpClient
.delete<HttpResponse | HttpErrorResponse>(`${this.host}/user/${userId}`); .delete<CustomHttpResponse | HttpErrorResponse>(`${this.host}/user/${userId}`);
} }
public addUsersToLocalStorage(users: User[]) { public addUsersToLocalStorage(users: User[]) {
@ -95,11 +95,5 @@ export interface UserPage {
} }
export interface HttpResponse {
timestamp: Date;
httpStatusCode: number;
httpStatus: string;
reason: string;
message: string;
}