I have a registration form. Step 1 user creates an account. As user creates an account I need to authenticate user with the created account.
in my account.service.ts I have following.
Is this the best way to handle this? and how can improve this to handle errors from 2 different http calls?
public createAccount(reg: CreateUserRequestModel): Observable<any> {
return this.apiService.post('api/register/account', reg)
.flatMap(()=>{
return this.authenticationService.authenticate(reg.emailAddress, reg.password)
}).map((response)=>{
return response.json()
})
.catch((error: any) => {
return Observable.throw(error.json());
});
}
return
of arrow functions..flatMap(() => this.authenticationService.authenticate(reg.emailAddress, reg.password)).map(response => response.json()).catch((error: any) => Observable.throw(error.json());
\$\endgroup\$