0
I am with 2 similar json, however, with one more constant in one of them. I’d like to match the 2 so I can reuse the same component and on the same call.
Ex.:
"data": [
{
"id": 1,
"titulo": "novaaaa",
"thumbnail": null,
"resumo": null,
"autor": {
"id": 1,
"name": "teste"
},
"tags": [],
...
}]
"data": [
{
"receitas": {
{
"id": 1,
"titulo": "novaaaa",
"thumbnail": null,
"resumo": null,
"autor": {
"id": 1,
"name": "teste"
},
"tags": [],
...
}
}]
His call is like this today:
this.service.getAll(type, id_type, '', this.page).subscribe(res => {
this.content = res.data.data;
}...
What is the best way and practice for me to match the 2 json and use it in this.content?
Hello, thank you so much for the reply. On remark 1 and 3, the return comes from the paginate standard of the Terminal that is doing the backend. On item 2, I actually just picked up an excerpt from the api return. So it seemed a little incomplete. In the example you did, is he considering the first position of the array, but using hasOwnProperty(), also meets in a loop? Thanks again.
– Rubens Junior
Yes meets within a loop normally, such as a foreach() or map() for example.
– LeAndrade
I did it, thank you very much! Note: in the loop it looks like this: this.content.map( Function( elem ) { if(elem.hasOwnProperty('recipes')) { Return elem['recipes']; } Return elem; });
– Rubens Junior
Good Rubens that’s right, success there!
– LeAndrade