Use the following code to check if it works.
<script src="//code.jquery.com/jquery-3.2.1.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(function () {
var currentUserEmail = _spPageContextInfo.userEmail;
// begin work to call across network
var requestUri = _spPageContextInfo.webAbsoluteUrl +
"/_api/web/Lists/getByTitle('StaffDirectory')/Items?$filter=Title eq '" + currentUserEmail + "'&$select=Section";
// execute AJAX request
$.ajax({
url: requestUri,
type: "GET",
headers: { "ACCEPT": "application/json;odata=verbose" },
success: function (data) {
if(data.d.results.length>0){
var mySection = data.d.results[0].Section;
getFileName(mySection);
}
},
error: function () {
alert("error found");
}
});
});
function getFileName(mySection){
// begin work to call across network
var requestUri = _spPageContextInfo.webAbsoluteUrl +
"/_api/web/Lists/getByTitle('SitePages')/Items?$filter=Section eq '" + mySection + "'&$select=FileLeafRef";
// execute AJAX request
$.ajax({
url: requestUri,
type: "GET",
headers: { "ACCEPT": "application/json;odata=verbose" },
success: function (data) {
if(data.d.results.length>0){
var CalFileName = data.d.results[0].FileLeafRef;
alert(CalFileName);
}
},
error: function () {
alert("Calendar not found");
}
});
}
</script>