Get URL From All Lists From Sharepoint Site Using PnP Javascript Library

PnP-JS-Core library contains the number of extensible methods and properties, using which, we can achieve various actions in a simple code. To know more about this library component, visit the below links:

In this post, we will discuss how to get default View URL from all lists in a SharePoint site using PnP-JS-Core library.

Example

The following code snippet returns title and default View URL from all lists in a SharePoint site, under browser console, using PnP JavaScript library. Click here to read more.

  1. <script type="text/javascript" src="/siteassets/scripts/fetch.js"></script>   
  2. <script type="text/javascript" src="/siteassets/scripts/promise.min.js"></script>   
  3. <script type="text/javascript" src="/siteassets/scripts/pnp.min.js"></script>  
  4.    
  5. <script type="text/javascript">  
  6. $pnp.sp.web.lists.select('Title''DefaultViewUrl').get().then(function(data) {  
  7.     for (var i = 0; i < data.length; i++) {  
  8.         console.log(data[i].Title + " - " + data[i].DefaultViewUrl);  
  9.     }  
  10. });  
  11. </script>