My web API returns multiple lists, such as employersList
and locationsList
.
Here is the current code I am using:
items = [];
constructor(private http: HttpClient) {}
getMember(){
this.http.get('http://apirequest').toPromise().then(data =>{
for(let key in data){
if(data.hasOwnProperty(key))
{
this.items.push(data[key])
}
}
})
}
Currently, I am writing all the data to a single array. How can I store the data in separate arrays?
Below is an example of the data I receive from the API request:
{
"employersList": [
{
"id": 2319259,
"employerName": "Jack Star",
},
{
"id": 4337496,
"employerName": "John Star",
}
],
"locationsList": []
}