0

I want to get a list of items from a SharePoint list, and display them in a specific way in SPFx webpart. I could use PnPJS to get Text and Number fields, but for the Author field, I am only getting the ID.

I'd like to get some other info, like email address, display name, and user image. My code now looks like this:

  sp.web.lists.getByTitle('Projects').items.get().then(items => {
           //console.log(items)
        })

However I am getting something like this:

enter image description here

How can I use AuthorId to get more info about that user?

0

You need to select the person field and use expand to get more information about the user like below

sp.web.lists.getByTitle('Projects').items.get().select('PersonField/FirstName,PersonField/LastName,PersonField/EMail').expand('PersonField').then(items => {
           //console.log(items)
})

Here are the values you can expand from the person field

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.