I'm trying to return value from a LookUp value to my dataTables. The only thing that returns is [object Object].
Here is an image of my List and result:
I searched that I should add $expand in my URL line however that did not work. Any suggestions? As you can I see I am having issues with my HyperLink column as well but I think I saw a solution on StackExchange so I'll look at that first.
Here is my code:
<script>
$(document).ready(function(){
GetItems();
});
function GetItems(){
//var siteUrl=_spPageContextInfo.webAbsoluteUrl;
var siteUrl="https://whatever.com";
var oDataUrl = siteUrl + "/_api/web/lists/getbytitle('datatabletest')/items?$select=Title,HyperLink,LookUp/Title&$expand=LookUp/Title";
$.ajax({
url:oDataUrl,
type:"GET",
dataType:"json",
headers:{
"accept":"application/json;odata=verbose"
},
success:OnSucces,
error:OnFailure
});
}
function OnSucces(data){
try{
$('#example').DataTable({
"aaData":data.d.results,
"aoColumns":[
{"mData":"Title"},
{"mData":"HyperLink"},
{"mData":"LookUp"}
]
});
}
catch(e){
alert(e.message);
}
}
function OnFailure(data, errMessage){
alert("Error: " + errMessage);
}
</script>