Search code examples
sharepoint-onlinecascadingdropdownspfx

SPFx: How to populate the dropdown with list names


I am trying to create a dropdown in the property panel of a webpart with SPFx and I found this tutorial: Use cascading dropdowns in web part properties

The problem with the sample is that is is using static data and I would like to know how to fetch the list names dynamically.

How can I do that? Best regards Americo


Solution

  • Use pnpjs library so you could get the lists easily.

    sp.web.lists.get().then((items:any[])=>{
          console.log(items.length);
          //to do, bind to dropdown
        })
    

    enter image description here