Working on a quick dashboard and I want to remove the second Object from departments_by_dept_emp. How would this be best achievable with Vue?
HTML
<tbody id="rows" v-for="result in results">
<tr>
<td>{{ result.first_name }} {{ result.last_name }}</td>
<td v-for="department in result.departments_by_dept_emp">{{ department.dept_name }}</td>
<td>{{ result.hire_date }}</td>
<td>{{ result.birth_date }}</td>
</tr>
</tbody>
JavaScript
{
"emp_no": 10010,
"birth_date": "1963-06-01",
"first_name": "Duangkaew",
"last_name": "Piveteau",
"gender": "F",
"hire_date": "1989-08-24",
"departments_by_dept_emp": [
{
"dept_no": "d004",
"dept_name": "Production"
},
{
"dept_no": "d006",
"dept_name": "Quality Management"
}
]
}
Axios call getting the data is stored in an empty array
data () {
return {
results: [],
}
}
Axios call
getData() {
this.loading = true
axios.get('https://url', { 'headers': { 'Api-Key': '' } })
.then(response => {
this.results = response.data.resource
this.next = response.data.meta.next
this.loading = false
console.log(response.data.resource)
})
.catch(error => {
console.log(error)
})
}
So from the example, essentially I only want the Production department name and remove Quality Management from my table. I do not believe slice() will do the trick as it will only clone one dimension. Also, anything like splice() or findIndex I receive the error "Cannot read property '{example}' of undefined""