Cześć, uczę się używać axios i chcę wyświetlić wszystkie nazwy klientów. Używam Laravel 9 i Vue 3. To jest mój kod w komponencie List.vue. Mój problem polega na tym, że ten kod nic nie wyświetla. Ktoś mógłby mi pomóc, gdzie robię błąd? Rouer jest poprawny. To mój kontroler po stronie backendu i komponent List.vue
Kontroller ClientsController.php
public function index()
{
$customers = $this->service->getList();
$response = [
'data' => $customers
];
return response()->json($response);
}
Komponent List.vue
<template>
<table>
<tr>
<th>Name</th>
</tr>
<tr>
<td>{{ clients.name }}</td>
</tr>
</table>
</template>
<script>
export default {
name: "List",
data() {
return {
clients: null
}
},
mounted() {
axios
.get('/clients')
.then(response => (
this.clients = response.data.clients
))
}
}
</script>