i am trying to transfer data from laravel to datatables. but in no way is the incoming data datatables loaded. where is the mistake? Laravel function and javascript are specified below. I have stated the result of the incoming data console below.
public function getTag()
{
$tag = Tag::all();
$data['data'] = $tag;
return $data;
}
async created() {
const res = await this.callApi('get', 'app/get_tags')
if (res.status === 200) {
console.log(res.data);
$("#datatables").DataTable({
data: res.data,
columns: [
{
data: "tagName",
},
]
});
} else {
console.log("error database");
}
}
{
"data": [
{
"id": 1,
"tagName": "asdasdasd",
"created_at": "2021-08-14T13:44:00.000000Z",
"updated_at": "2021-08-14T13:44:00.000000Z"
},
{
"id": 2,
"tagName": "asdasd",
"created_at": "2021-08-14T13:45:03.000000Z",
"updated_at": "2021-08-14T13:45:03.000000Z"
},
{
"id": 3,
"tagName": "asdasd23",
"created_at": "2021-08-14T13:45:26.000000Z",
"updated_at": "2021-08-14T13:45:26.000000Z"
},
{
"id": 4,
"tagName": "asdasd23231",
"created_at": "2021-08-14T13:46:17.000000Z",
"updated_at": "2021-08-14T13:46:17.000000Z"
}
]
}