Hi @Meet Bhatt ,
You could use the bleow to get all documents from all the libraries in the site:
let getFiles = (folderUrl) => {
sp.web.getFolderByServerRelativeUrl(folderUrl)
.expand("Folders, Files").get().then(r => {
r.Folders.forEach((item) => {
if (item.Name !== "Forms") { //ignore Edit/DisplayForm folders
getFiles(item.ServerRelativeUrl);
}
});
r.Files.forEach((item) => {
console.log(item.ServerRelativeUrl);
});
});
};
sp.site.getDocumentLibraries("https://tenant.sharepoint.com/sites/test").then(function(data){
for(let d of data){
console.log(d.ServerRelativeUrl);
getFiles(d.ServerRelativeUrl);
}
});
Similar question is here: https://sharepoint.stackexchange.com/questions/289043/get-all-files-in-a-site-collection-with-pnpjs/289051#289051
If an Answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.