How would I correctly access the nested json for stage.name in the example below?
You can see in the template I am trying to access stage name.
vue.js
created() {
url="http://{{ api_endpoint }}"
fetch(url)
.then(response => response.json())
.then(body => {
for(i=0; i<body.length; i++){
this.job_execs.push({
'name': JSON.stringify(body[i].job.name),
'build_id': JSON.stringify(body[i].build_num),
'env': JSON.stringify(body[i].job.env),
})
}
})
template: `
<li v-for="item in this.job_execs">
[[ item.build_num ]]
<li v-if="stage in item.job">
[[ stage.name ]]
</li>
</li>
</ul>
example api
[
{
"build_num": 12,
"job": {
"name": "test-job",
"env": "DEV",
"tool": {
"env": "DEV",
},
"product": {
"name": "vuejs"
},
"platform": {
"name": "none"
},
"stage": [
{
"name": "stage1"
},
{
"name": "stage2"
},
{
"name": "stage3"
},
]
},
]
I am guessing I need to create a new list in the created hook and start pushing the stage names? But then I will have two lists? Not sure what is the best way to do this.