When trying to implement the following code in SharePoint 2016, I get the following error:
Unable to get property 'webAbsoluteUrl' of undefined or null reference.
The developer tool points to this line var absoluteURL = _spPageContextInfo.webAbsoluteUrl;
function getData(lName){
var absoluteURL = _spPageContextInfo.webAbsoluteUrl;
if(lName == "Navigation"){
console.log(_spPageContextInfo.webAbsoluteUrl);
var endPointUrl = absoluteURL + "/_api/web/lists/getbyTitle('"+lName+"')/items";
}else{
console.log(_spPageContextInfo.webAbsoluteUrl);
var endPointUrl = absoluteURL + "/_api/web/lists/getbyTitle('"+lName+"')/items?$select=parentNav/URL, parentNav/URLNAME,subLink&$expand=parentNav";
//console.log(endPointUrl);
}