register(email: string, password: string, firstName: string, lastName: string,location: string): Observable<UserRegistration> {
let body = JSON.stringify({ email, password, firstName, lastName,location });
let headers = new Headers({ 'Content-Type': 'application/json' });
let options = new RequestOptions({ headers: headers });
return this.http.post(this.baseUrl + "/accounts", body, options)
.map(res => true)
.catch(this.handleError);
}
I found this code online, and i'm trying to implement it in my own project, but i keep getting the follow error:
Type 'Observable<boolean>' is not assignable to type 'Observable<UserRegistration>'.
Type 'boolean' is not assignable to type 'UserRegistration'.
it also uses this class:
export interface UserRegistration {
email: string;
password: string;
firstName: string;
lastName: string;
location: string;
}
As your method shows , you are returning a boolean true , while your definition says it should return Observable<UserRegistration>
. Change your method return type as,
register(email: string, password: string, firstName: string, lastName: string,location: string): Observable<boolean>
However your logic does not seem to be right as it always going to return true.