sharepointspfxpnp-js

read document urls in a sharepoint library via pnp Js ver 3


I am using pnp.js ver 3 libary to read some images within a document library. But the following two functions do not return the url/FileRef or even the Name of the stored document. Even if i explicitly specify the url column(s) in viewXml node of Came

Any idea how we can read the url via pnp ?

eg

await sp.web.lists.getByTitle(constants.visualsList).items.getAll()

 await sp.web.lists.getByTitle(constants.visualsList).getItemsByCAMLQuery({
       ViewXml: `<View><ViewFields>
       <FieldRef Name='Title' />
       <FieldRef Name='EncodedAbsUrl' />
       <FieldRef Name='FileRef' />
       </ViewFields>
       <Query><Where>....

Solution

  • This works for me:

    await sp.web.lists.getByTitle(constants.visualsList).items.select('Title', 'EncodedAbsUrl', 'FileRef', 'FileLeafRef', 'ID').getAll()
    

    Please if it does not work, write response from this call.