How To: Query List on Different SharePoint

How do I use pnp to query a list that is in a different SharePoint but still in my collection?

Hello @smithme,

Please use the following code to get list items from another site.

let web = new Web('SiteURL');

web.lists.getByTitle("ListName").items.get().then(function(items) {
                //items array
                console.log(items);
            });
1 Like

Thank you so much for your help!

1 Like

Is it possible to filter by filename ?

Hello @Chris_Grist,

Yes, you can filter documents that are stored in the library by file name with the following code:

pnp.sp.web.getFolderByServerRelativeUrl("/sites/Main/Shared%20Documents").files.filter("fileName'").get().then(function(files) {
                console.log(files)
            });