How to populate the dropdown with list names

%3CLINGO-SUB%20id%3D%22lingo-sub-667270%22%20slang%3D%22en-US%22%3EHow%20to%20populate%20the%20dropdown%20with%20list%20names%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-667270%22%20slang%3D%22en-US%22%3E%3CP%3EHi%2C%3C%2FP%3E%3CP%3EI%26nbsp%3B%3CSPAN%3E%26nbsp%3Bam%20trying%20to%20create%20a%20dropdown%20in%20the%20property%20panel%20of%20a%20webpart%20with%20SPFx%20and%20I%20found%20this%20tutorial%3A%3C%2FSPAN%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fsharepoint%2Fdev%2Fspfx%2Fweb-parts%2Fguidance%2Fuse-cascading-dropdowns-in-web-part-properties%23create-new-project%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3EUse%20cascading%20dropdowns%20in%20web%20part%20properties%3C%2FA%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%3EThe%20problem%20with%20the%20sample%20is%20that%20is%20is%20using%20static%20data%20and%20I%20would%20like%20to%20know%20how%20to%20fetch%20the%20list%20names%20dynamically.%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%3EHow%20can%20I%20do%20that%3F%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%3EBest%26nbsp%3B%20regards%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3EAmerico%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-667270%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EDeveloper%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-682195%22%20slang%3D%22en-US%22%3ERe%3A%20How%20to%20populate%20the%20dropdown%20with%20list%20names%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-682195%22%20slang%3D%22en-US%22%3EHi%20%40America%3CBR%20%2F%3EYou%20can%20load%20all%20lists%20from%20current%20site%20or%20specific%20site%20collection%20by%20calling%20SharePoint%20REST%20API%20using%20SPHttpClient%20class%20of%20SPFx%20or%20you%20can%20use%20fluent%20APIs%20of%20%40PnP%20which%20is%20great%20wrapper%20around%20SharePoint%20APIs.%3CBR%20%2F%3E%3CBR%20%2F%3EYou%20can%20more%20details%20about%20SPHtppClient%20class%20here%3CBR%20%2F%3E%3CBR%20%2F%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fjavascript%2Fapi%2Fsp-http%2Fsphttpclient%3Fview%3Dsp-typescript-latest%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fjavascript%2Fapi%2Fsp-http%2Fsphttpclient%3Fview%3Dsp-typescript-latest%3C%2FA%3E%3C%2FLINGO-BODY%3E
Highlighted
Regular Contributor

Hi,

 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

1 Reply
Highlighted
Hi @America
You can load all lists from current site or specific site collection by calling SharePoint REST API using SPHttpClient class of SPFx or you can use fluent APIs of @PnP which is great wrapper around SharePoint APIs.

You can more details about SPHtppClient class here

https://docs.microsoft.com/en-us/javascript/api/sp-http/sphttpclient?view=sp-typescript-latest