-3
I make a request, where search data of a request, where it returns me the "Areas" and saved inside an array. I make an iterator to search the "topics" referring to that "Area", I wanted to put this return, within the same array, but with a new position, with the data referring to the "Areas"
Return of the first request Return requests that are generated from the first request
The goal is to place these second data within the first Array
Something like that would come up
id: 1
parent_id: 0
product_id: 1
name: "Clínica Médica"
photo: "http://simsave.s3-website.us-east-2.amazonaws.com/public/topics/{size}/1565627445064.jpg"
description: null
type: [""]
medicine: 1
nursing: 0
nursing_tech: 0
"dados":Array([0..9]) // Aqui com os valores do primeiro retorno
this.api.Get("../topic/product/listProducts?product_id=" + id).subscribe((res: any) => {
let topics = [res.length];
for(let i:number = 0; i < res.length; i++){
topics[i] = res[i];
this.api.Get("../topic/parent/listProductParent?parent_id=" + topics[i].id).subscribe((ret: any) => {
topics[i].push(ret);
});
}
console.log(topics);
});
please enter the result of the request, we do not have access to this API, so we cannot write a response about something we do not know.
– Paz
I just put it here @Paz
– gabrielfalieri
Manual on how NOT to ask questions - Post code as image
– Sorack
If I understand correctly, you make a request that returns an array of objects. Inside this object you want to use the id of each one to pick up other objects that contain the property parent_id equal to the id of these objects. And inside the "parent" object you want to fill a given property with the objects of the second request that have parent_id equal to id.
– Paz
Yeah, that’s confusing but that’s it
– gabrielfalieri
@Peace is just that
– gabrielfalieri
in fact, no and well that you answered, we will open a chat?
– gabrielfalieri
can open the chat...
– Paz
all right, I’ll open
– gabrielfalieri
I opened a room but couldn’t add you @Paz
– gabrielfalieri
pass the link please
– Paz
Let’s go continue this discussion in chat.
– gabrielfalieri