>
> Hi Sander,
>>
>
> I get error in the call of *.**map(this.secondstep) **in the
> GetResult method*
> EXCEPTION: Cannot read property 'get' of undefined
>
> As you see below, call to
>>
>> * this.getUserGroups() works but when calling *
>>
>> * .map(this.getUserProps) it fails*
>
>
>>>>
>>>>
>>>> * IsEditable() { console.log("IsEditable ..."); return
>>> this.getUserGroups() .map(this.getUserProps)
>>> .subscribe(data => { /* all data is available here */
>>> console.log("Is Editable ... " + JSON.stringify(data))
>>> }); } getUserProps(data) { console.log("getUserProps ...");
>>> let header = new Headers(); header.append("Content-Type",
>>> "application/json; odata=verbose"); header.append("Accept",
>>> "application/json; odata=verbose"); return this.http.get(this._url,
>>> { headers: header }).map((response: Response) =>
>>> response.json()) .map((r) => data.getUserProps = r); }*
>>
>>
> Thank you
>
On Monday, March 6, 2017 at 8:41:22 PM UTC-8, Sander Elias wrote:
>
> Hi Celerity,
>
> If you want synchronous results, you need to use native JS, as Angular
> doesn't provide that.
> However, you can easily string multiple async calls together.
>
> might look like this:
> import { Injectable } from '@angular/core';
> import { Http, Headers, Response } from '@angular/http';
>
> @Injectable()
> export class ServiceNameService {
>
> constructor(private http:Http) { }
>
> getResult() {
> return this.firststep()
> .map(this.secondstep)
> .map(this.thirthstep)
> .subscribe(data => {
> /* all data is available here */
> });
> }
>
> firststep() {
> return this.http.get('url')
> .map((response: Response) => response.json())
> .map(data => ({firstep: data}))
> ;
> }
>
> secondstep(data) {
> /* use data to prepare call */
> return this.http.get('url')
> .map((response: Response) => response.json())
> .map((r) => data.secondStep = r);
> }
>
> thirthstep(data) {
> /* use data to prepare call */
> return this.http.get('url')
> .map((response: Response) => response.json())
> .map((r) => data.thirthStep = r);
> }
>
> }
>
> Hope this helps you a bit,
> Regards
> Sander
>
>
>
>
>
--
You received this message because you are subscribed to the Google Groups
"Angular and AngularJS discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.