async function getRequestHistory(id) {
var response = await fetch(Urls.api_1_add_forge_request_get(id));
var data = await response.json();
var history = data.history;
var item = history.filter(item => item.actor_role === 'MODERATOR');
if (item.length > 0) {
return item[0].actor;
}
return '';
}
Inside the data table:
{
data: 'id',
name: 'Admin Name',
render: function(data, type, row, meta) {
var adminName = getRequestHistory(data);
// get value from promise
adminName.then(function(value) {
console.log('Value is ' + value);
window.adminName = value;
return value;
});
console.log('This is the response ' + window.adminName); //undefined because its synchronous
return 'Return Comes Here';
}
},