PnP-JS-Core: Get url from all lists from SharePoint Site

This post contains the code example to get all lists with specified properties from site using PnP JavaScript Library.

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

Simplified JavaScript Library for SharePoint

PnP-JS-Core Library

This post explains,

How to get URL of all lists in SharePoint site using PnP JavaScript Library.


The below steps and code snippet used to return all title and URLs from all lists in a SharePoint site using PnP JavaScript library,

  1. Download Required files to use PnP-JS-Core library from the below links and upload that to Site Asstes or Style Library
    • Download pnp.js  PnP JS file
    • Download fetch.js Used by PnP js file to handle web requests and responses (Required in IE)
    • Download promise.js Used by PnP js file to handle web requests and responses (Required in IE)
  2. Create new web part page and insert Content Editor web part
  3. Create a sample.html file in Site Assets or Style library and insert the below code snippet

    [code language=”javascript”]

    <script type="text/javascript" src="/siteassets/scripts/fetch.js"></script>
    <script type="text/javascript" src="/siteassets/scripts/promise.min.js"></script>
    <script type="text/javascript" src="/siteassets/scripts/pnp.min.js"></script>

    <script type="text/javascript">
    $‘Title’, ‘DefaultViewUrl’).get().then(function(data) {
    for (var i = 0; i < data.length; i++) {
    console.log(data[i].Title + " – " + data[i].DefaultViewUrl);


  4. Add the URL of sample.html file to the content editor web part
  5. Click ok to apply the changes to the web part and save the page.
  6. The page returns the all lists title and default url in a browser’s console log .
Shantha Kumar
Shantha Kumar
Articles: 269

One comment

Leave a Reply

Your email address will not be published. Required fields are marked *