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?

1 Answers1

1

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

Vipul Kelkar
  • 1,534
  • 2
  • 14
  • 25