Get items of Site Pages using pnp getByTitle

Copper Contributor


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

@amha97 Have you read this this documentation?

@Beau Cameron Yes I have read it and as I understand it this

sp.web.lists.getByTitle("My List").items.get().then((items: any[]) => {

Should work for “Site Pages” also and as I mentioned, when i tried the same thing in my other SharePoint account it did work just fine.