I have the following response from my http server:
sites
[
{
"siteName": "Site de Marseille",
"siteAdress1": "rue de blabla",
"siteAddress2": "string",
"siteCodPost": "13010",
"siteTown": "Marseille",
"points": [
{ "lat": 44.841225, "lng": -0.580036 },
{ "lat": 44.842236, "lng": -0.64696 },
{ "lat": 44.805615, "lng": -0.63084 }
],
"id": "5d0ce7c4a06b07213a87a753",
"companyId": "5cd430745304a21b9464a219",
"customerId": "5cd430c65304a21b9464a21a"
},
{
"siteName": "Site de Bordeaux",
"siteAdress1": "rue de la Garonne",
"siteAddress2": "string",
"siteCodPost": "31000",
"siteTown": "Bordeau x",
"points": [
{ "lat": 44.819868, "lng": -0.582811 },
{ "lat": 44.853709, "lng": -0.483573 },
{ "lat": 44.80696, "lng": -0.53299 },
{ "lat": 44.80696, "lng": -0.629078 }
],
"id": "5d0cf65fa06b07213a87a754",
"companyId": "5cd430745304a21b9464a219",
"customerId": "5cd430c65304a21b9464a21a"
}
]
These are 2 sites and for each site a property called points that is an array. My wish is to extract each points arrays independently and push them to another array. This new array will be an array of arrays.
For this, I have this code:
this.customerApi.getSites(this.currentUser.id)
.subscribe(response => {
this.sites = response;
const ok = this.sites.map(s => s.points);
this.rectangles.push(ok);
});
I am getting an Observable() from my API (see above), and I use the .map transformation. My problem is that it creates an array and my code pushes that array composed by arrays of points.
I want to push each array of points instead of an array of array (created by .map) of points.
Is there please any simple way to resolve this?
Best Regards.