Я относительно новичок в Vue и пытаюсь организовать ответ API по странам, а затем по штатам. Ниже приводится пример ответа от API:
[
{
"id": 1,
"title": {
"rendered": "Test 1"
},
"acf": {
"address_property": {
"city": "Lenox",
"state": "Massachusetts",
"country": "United States",
}
}
},
{
"id": 2,
"title": {
"rendered": "Test 2"
},
"acf": {
"address_property": {
"city": "Branson",
"state": "Missouri",
"country": "United States",
}
}
},
{
"id": 3,
"title": {
"rendered": "Test 3"
},
"acf": {
"address_property": {
"city": "Branson",
"state": "Missouri",
"country": "United States",
}
}
},
{
"id": 4,
"title": {
"rendered": "Test 4"
},
"acf": {
"address_property": {
"city": "Tallinn",
"country": "Estonia",
}
}
}
]
У меня успешно печатается код на странице, однако мне не удалось систематизировать эту информацию. Вот идеальный результат:
США
Массачусетс
Миссури
Международный
Эстония
Текущий код, который у меня есть:
data: function() {
return {
properties: []
};
},
methods: {
loadDestinations: function() {
axios
.get("//localhost:81/wp-json/wp/v2/properties?_embed")
.then(response => {
sessionStorage.setItem("properties", JSON.stringify(response.data));
this.properties= response.data;
return response.data;
})
.catch(error => {
console.error(error); // for debugging maybe
});
}
},
mounted() {
if (sessionStorage.getItem("properties")) {
this.properties= JSON.parse(sessionStorage.getItem("properties"));
} else {
this.loadDestinations();
}
}