So I'm very new to Angular2, and trying to iterate through http response I'm kindda stuck. With the following code :
ngOnInit() {
this._meetService.getAuth( "meets/"+ this.meetId + "/participants").subscribe(
meet => {
this.participants = meet.participants;
this.organizators = meet.organizators;
console.log(this.participants);
},
error => console.log("error")
)
}
I get values in both this.participants and this.organizators but with the following :
ngOnInit() {
this._meetService.getAuth("meets/"+ this.meetId + "/participants").subscribe(
meet => {
meet.participants.forEach(participant => this.members.push(participant));
meet.organizators.forEach(organizator => this.members.push(organizator));
console.log(this.members);
},
error => console.log("error")
)
}
I get the error logged. How can this be ?
Here the getAuth() method :
@Injectable()
export class MeetService {
constructor(private http: Http, public api: ApiConfig, private _routeParams: RouteParams) {}
getAuth(path: string) {
var auth = this.api.headers();
auth.append("X-Auth-Key", "azertyuiop...");
return this.http.get(this.api.getPath(path), {headers: auth})
.map(res => <any> res.json())
}
}
getAuthmethod code..should have returnobservableobject.error => console.log("error")