0👍
✅
Allright, one useful strategy to debugging these sorts of problems,
in your template add:
<pre>{{$data}}</pre>
So you can see all the data that is available to you in your template.
As for why it isn’t working. You receive batchResource from your server which is an array: [ $batchResult, $batchResult ]
,
Either change your searchBatch function to adapt to this situation, like so:
searchBatch(){
axios.post('/search-results', this.form).then((res)=>{
// res.data = [ $batchResult, $batchResult ]
// take the first list of results:
this.batchResource = res.data[0]
this.display = true
console.log(res.data)
})
}
Or don’t change the search function and deal with it in your template:
<tr v-for="batch in batchResource[0]" :key="batch.id">
<th scope="row">{{batch.patient_number}}</th>
<td>{{batch.patient_name}} | {{batch.patient_gender}}</td>
</tr>
Source:stackexchange.com