app/dxa/dxa-entity/views/my-profile-views/my-profile.service.ts
Methods |
constructor(httpClient: HttpClient)
|
||||||
Parameters :
|
postUser | ||||||
postUser(user: User)
|
||||||
Parameters :
Returns :
Observable<any>
|
import { Injectable } from '@angular/core';
import { User } from './my-profile.model';
import { HttpClient, HttpHeaders, HttpErrorResponse } from '@angular/common/http';
import { Observable, throwError } from 'rxjs';
import { AppConfig } from '../../../../app.config';
import { catchError } from 'rxjs/operators';
@Injectable({
providedIn: 'root'
})
export class MyProfileService {
constructor(private httpClient: HttpClient) {}
postUser(user: User): Observable<any> {
const httpOptions = {
headers: new HttpHeaders({
'Content-Type': 'application/json'
}),
observe: 'response' as 'response'
};
return this.httpClient.post(AppConfig.settings.registerUser.url, JSON.stringify(user), httpOptions)
.pipe(catchError((error: HttpErrorResponse) => {
return throwError(error.status);
}));
}
}