I'm trying to use values obtained from an API that return the values in JSON.
I can see the values of the object in the console. But I can not use them apart.
How do I assign values in different variables, separately?
I want to validate the data before sending it to the HTML.
this.http
.get(this.url + e)
.map((res) => res.json())
.subscribe((data) => this.user = data);
OR
getData() {
let e = md5(this.userString);
this.http
.get(this.url + e)
.map((res) => res.json())
.subscribe(
user => this.user = user,
error => this.errorMessage = <any>)}
Thank You
Sorry I can't add comments but I think it is in the html page, call the function in a certain div, then call the data with the specified information you want, for example in your case it is like that:
<div click()= "getData()">
<p *ngFor="let i of data"> {{i.username}}
<p *ngFor="let i of data"> {{i.id}}
if the data was array it would work.
This is how I understand your question.