Skip to content

Instantly share code, notes, and snippets.

@sharikovvladislav
Created August 29, 2017 11:36
Show Gist options
  • Save sharikovvladislav/041da37b87c1f74976799c548065fcf2 to your computer and use it in GitHub Desktop.
Save sharikovvladislav/041da37b87c1f74976799c548065fcf2 to your computer and use it in GitHub Desktop.
private getGroups(): Observable<any> {
// ....
return this.http.get(_url, options)
.map(response => {
var responseAsObject = response.json();
console.log(responseAsObject);
return responseAsObject;
})'
}
@sharikovvladislav
Copy link
Author

Show me your current getGroups implementation.

@itanimo
Copy link

itanimo commented Aug 29, 2017

private getGroups() : Observable {
console.log("In Groups");
let _url = "http://url.....";
let headers = new Headers();
headers.append('X-User', sessionStorage.getItem('username'));
headers.append('X-Token', sessionStorage.getItem('token'));
headers.append('X-AccessTime', sessionStorage.getItem('AccessTime'));
headers.append('Content-Type', 'application/json');
let options = new RequestOptions({ headers: headers });

return this.http.get(_url, options)
.map(response => {
  var responseAsObject = response.json();
  this.roles = responseAsObject;
})

}

@sharikovvladislav
Copy link
Author

so how do you expect this work?

My code: https://gist.github.com/sharikovvladislav/041da37b87c1f74976799c548065fcf2#file-lulz-L7. Note return statement.

Your code:

return this.http.get(_url, options)
.map(response => {
  var responseAsObject = response.json();
  this.roles = responseAsObject;
})

You return undefined. Thats why you get undefined in the usage.

@sharikovvladislav
Copy link
Author

Did that solved your problem?

@itanimo
Copy link

itanimo commented Aug 29, 2017

Sort of, even if I return the variable I can't map it to my array. But you helped clarify part of the problem so I have that to thank you :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment