Forum Discussion

amha97's avatar
amha97
Copper Contributor
May 07, 2019

Get items of Site Pages using pnp getByTitle

Hi, 

I am trying to retrieve Site pages items by using pnp getByTitle, as shown below.

 

    let web = new Web (this.context.pageContext.web.absoluteUrl);

    web.lists.getByTitle('Site Pages').items.get().then(console.log);

 

and I have established context (spfxContext: this.context and context: this.context) in the .ts File.

 

On the console log I keep getting the same error every time, which is, it couldn’t find the list 'Site Pages'.

 

I know the code works properly because it gets all the items when I tried it on in one of my other tenants. So, I’m guessing the problem lies somewhere in my tenant Site Pages settings.

Can someone help me with this issue?

2 Replies

Resources