Я получаю данные в ответ, но не могу добавить их в строку данных.Может кто-нибудь помочь мне с этим?
Это то, что я пытаюсь сделать:
export default (id) => {
if (!$.fn.dataTable) return;
$('#'+id).DataTable({
destroy: true,
pageLength: 8,
responsive: true,
ordering: false,
searching: false,
info: true,
lengthChange: false,
stripeClasses: [],
processing: true,
serverSide: true,
ajax: {
url : `${Config.baseUrl}/homepark/list?page_no=1&settingType=dashboard&isActive=1&categoryId=active-listings`,
type : 'GET',
"beforeSend" : function(xhr) {
xhr.setRequestHeader('userToken',localStorage.getItem('accessToken'));
},
"dataSrc": function ( json ) {
const data = json.response.users
console.log('@@@', data);
// data = data.row\````
},
},
});
};
Это то, что я получаю в результате от бэкэнда в json.response.users
:
(4) [{…}, {…}, {…}, {…}]
0: {name: "testt", data: "0"}
1: {name: "testt11", data: "1"}
2: {name: "testt11", data: "2"}
3: {name: "testt11", data: "3"}
length: 4
__proto__: Array(0)