I need to get the URL of each individual files in a SharePoint library (Case Documents). At the moment I'm using:
sp.web.lists.getByTitle("Case Documents").items.get().then((items: any[]) => {
let returnedItems: IListCItem[] = items.map((item) => { return new ListCItem(item); });
this.setState({
ListCItems: returnedItems,
}, () => {
console.log(this.state.ListCItems);
});
});
// sp.web.lists.getByTitle("Case Documents").items.select("ID","Title","CaseID/Title","CaseID/ID").expand("CaseID").get().then((items: any[]) => {
// let returnedItems: IListCItem[] = items.map((item) => { return new ListCItem(item); });
// console.log(returnedItems);
// this.setState({
// ListCItems: returnedItems,
// });
// });
...to get the list of file names. I've struggled with getting lookup columns using the commented out code as you can see. I included that to show you how what I've used.
Can someone tell me how to get the URL of each file so I can then create clickable links for each document in the web part I'm creating.
I've looked at: https://github.com/SharePoint/PnP-JS-Core/wiki/Working-With:-Files but it's not clear to me. I'm guessing something like:
pnp.sp.web.getFolderByServerRelativeUrl("/sites/dev/documents").files.getByName("file.txt").getText().then((text: string) => {});