Skip to main content
1 of 3

Need help with lookups in SPFX with REST

I'm new to SPFX and still trying to find my way around. At the moment I'm struggling to access lookup fields from site pages using REST, currently not using PNP or other libraries, trying to stay vanilla for simplicity. I can manage CRUD for most fields in the pages library, but I'm not finding a way to access lookup field values. I realize this is a n00b request, but any help would be apppreciated.

The current requirement is to create a simple web part that will go onto the intranet landing page. It takes a single page URL as a property, validate that the URL uses a specific custom content type, and then display the article date, content type, comments, rollup image and a 'Read more' button linking to the page from the url property.

My current approach is roughly:

export interface ISPList { //...other fields... contentType: any; Id: string; Url: any; PublishingRollupImage: any; }

and

 private _getListData(): Promise<ISPLists> {

return this.context.spHttpClient.get(this.context.pageContext.web.absoluteUrl + /_api/web/lists/GetByTitle('Pages')/Items, SPHttpClient.configurations.v1).then((response: SPHttpClientResponse) => {
debugger; return response.json(); }); }

This works for the most part, but doesn't include values for the content Type, rollup image or url. Suggestions on accessing the fields mentioned, please?