I have an object that comes from the backend.
{
"status": "success",
"message": null,
"data": {
"current_page": 1,
"data": [
{
"id": 41,
"provider_name": "12312",
"provider_bin": "123123123123",
"contract_number": null,
"contract_date": null,
"provider_address": null,
"provider_category_id": 5,
"budget_classification_code_id": null,
"provider_phone": null,
"provider_head_name": null,
"provider_call_centre": null,
"sector_economies_id": 6,
"calculation_type_id": 3,
"region_id": 3,
"additional_bank": [
{
"id": 1,
"providers_list_id": 41,
"bank_id": 20,
"bank_account_number": "3123123123123",
"service_id": 6,
"tariff_name": "31231231",
"additional_bank_house": {
"id": 1,
"additional_bank_id": 1,
"house_id": 4,
"house": {
"id": 4,
"house": "23",
"city": null,
"region": null,
"street": null,
"street_type": null,
"address": " , , ",
"improvement_degree_title": null,
"region_name": null,
"city_name": null,
"street_name": null
}
}
}
]
}
]
}
}
I can pull out additional_bank
through a loop. But inside it is additional_bank_house -> house
, How can I get it out ?
So that I can let's add 1 element with house_id 5 (on the frontend it's a multiple select )
I would be grateful if you provide an example code that would allow you to pull data from additional_bank_house -> house
, because if this succeeds, then they will automatically be substituted in multiple select
FRONTED: vue3
BACKEND: Laravel
CodePudding user response:
Try this :
data.data.forEach(({ additional_bank }) => {
additional_bank.forEach(({ additional_bank_house }) => {
console.log(additional_bank_house.house.house)
})
})