I am using the following code to get the current logged in user to a SP page. I'm only able to get the Title. How can I get the email address as well? Thank you.
// Get current user
jQuery.ajax({
url: "https://.../_api/web/currentuser?$select=Title,User/ID,User/EMail&$expand=User",
type: "GET",
headers: {"Accept": "application/json;odata=verbose","Content-Type": "application/json;odata=verbose"},
success: function(data) {
username = data.d.Title;
console.log(data.d);
console.log("user name: " + username);
document.getElementById("user").innerHTML = username;
},
error: function(data) {
console.log("Error occurred trying to get user id");
}
});