Forum Discussion
Americo Perez
Apr 23, 2018Iron Contributor
SPFX Getting "undefined" when asking for author name.
Hi, I am testing sp-pnp-js and for that I choose get information from the Site Pages library. More specific I am trying to get the "Description", "Title" and "Author" properties of the items in th...
Gautam Sheth
Apr 25, 2018Brass Contributor
Author is a field of type people or group. It is actually a kind of lookup column. So, to retrieve the value, you need "expand" it.
Modify your REST endpoint as :
pnp.sp.web.lists.getByTitle("Site Pages").items.select("Title", "Description", "Author/Title","Author/Name").expand("Author").get().then((response) => {
console.log(response);
});
This will get the response as in the below screenshot, you need to make necessary change in your code:
- Americo PerezApr 26, 2018Iron ContributorThanks! I will test it in the weekend 👍