File

app/dxa/dxa-entity/views/my-profile-views/my-profile.service.ts

Index

Methods

Constructor

constructor(httpClient: HttpClient)
Parameters :
Name Type Optional
httpClient HttpClient No

Methods

postUser
postUser(user: User)
Parameters :
Name Type Optional
user User No
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);
		}));
	}
}

result-matching ""

    No results matching ""