import 'rxjs/add/observable/of'; import 'rxjs/add/operator/delay'; import { Injectable } from '@angular/core'; import { HttpClient, HttpHeaders } from '@angular/common/http'; import { Observable } from 'rxjs/Observable'; @Injectable() export class MyAccountLoginPortal { constructor(private http: HttpClient) { } post(url: string, payload: any, customHeaders: any, lang: string): Observable { // For some reason, AEM is expecting payload as parameters. const data = Object.keys(payload).map(key => `${encodeURIComponent(key)}=${encodeURIComponent(payload[key])}`).join('&'); const httpOptions = { headers: new HttpHeaders({ ...customHeaders }) }; return this.http.post(url, data, httpOptions); } }