I'm creating a SharePoint SPFx web part app.
Using PnPjs I'm able to retrieve the current logged in user's information:
sp.web.currentUser.get().then((response : CurrentUser) => {
console.log(response);
this.setState({
getEmail: response["Email"],
});
})
In the currentUser
array we have access to the id, title, email address, and etc. If I wanted to add another key
to the currentUser
array how would I go about doing that.
For example I'm building a shop app. I want to add role
column or a preferredMember
column to that user. Which I can select decide if the user is a preferred member or not.
The end result I should get something like this in my console.log(response);
odata.type: "SP.User"
odata.id: "hidden for privacy"
odata.editLink: "Web/GetUserById(13)"
Id: 13
IsHiddenInUI: false
LoginName: "i:0#.f|membership|[email protected]"
Title: "John Smith"
PrincipalType: 1
Email: "[email protected]"
Role: "Product Tester"
PrefferedMember: "No"