How to get sharepoint file custom metadata using PnP.js

Using PnP.js, I can get the files under a folder

const files = await sp.web.getFolderByServerRelativeUrl("/sites/mysite/mylib/docs").files.get();

But it doesn't return the custom metadata for the files. It only returns the standard column values (such as Title, Name, TimeLastModified, ...). How to get all the metadata for files?

1 answer

  • answered 2021-06-23 08:18 Matej

    I had similar problem and the solution for me was to expand deferred property of files like this:

    sp.web.getFolderByServerRelativePath(...).files.expand('ListItemAllFields', 'Author').get();