Looking into the documentation of DataTables I see that they expect a different format in JSON than Laravel is sending back by Laravel. Probably because of that it's not working.
So your current response is this:
{
"data": [
{
"id": 1,
"name": "Eladio Schroeder Sr.",
"email": "[email protected]",
},
{
"id": 2,
"name": "Liliana Mayert",
"email": "[email protected]",
}
]
}
However datatables expects this
{
"data": [
{
1,
"Eladio Schroeder Sr.",
"[email protected]",
},
{
2,
"Liliana Mayert",
"[email protected]",
}
]
}
So basically no keys and just enough lines for the table to fill.
So you can update your UserResource to this and it should work
public function toArray($request)
{
return [
$this->id
$this->name
$this->email
];
}
Let me know if that works for you!