Hi,
I am working in SPFx with the version of 1.10.0. I am using the below code to get the files and folders of document libraries by passing the relative url. I am able to get the fields like Title, Name, ServerRelativeUrl, TimeCreated, TimeLastModified and so on.
I want to get the fields like Created By (Author), Modified By (Editor) and Checkoutuser. How to get it using PnP JS?
public getFilesFoldersFromList(relativeUrl: string): Observable<any> {
return from(
sp.web
.getFolderByServerRelativeUrl(relativeUrl)
.expand("Folders", "Files")
.get()
).pipe(
map((res: any) => {
return res;
})
);
}
Please help me.
Hi @spvjebaraj,
You can get these from files' item information:
sp.web.lists.getByTitle('Shared Documents')
.rootFolder.files
.select('*,listItemAllFields')
.expand('listItemAllFields')
.get().then(console.log);
Hi Andrew,
Thanks for your answer to get all the fields for the document library. But I want to get the details of files which is presented inside the folder. For example my relative path should be, "sites/testsite/Media/Folder1".
How to get this?
It's generic, man! :D
sp.web.getFolderByServerRelativeUrl('/sites/testsite/Media/Folder1')
.files
.select('*,listItemAllFields')
.expand('listItemAllFields')
.get().then(console.log);
Just now I also tried this. It's working. I thought to reply back to you.
But you did it.
Thanks for the solution.