function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Kishore Vamsi 6Kishore Vamsi 6 

How to get first value in list of strings in LWC

I want to capture first values in list of string using js controller. my apex getListofString returning list strings.

 
nameList =[];
firstValue='';
getListofString().then(data => {
                this.nameList = data;
               this.firstValue=?
                
        })
SwethaSwetha (Salesforce Developers) 
HI Kishore,
Does using  this.firstValue=data[0] work for your scenario?The below articles might help:
https://salesforce.stackexchange.com/questions/271003/accessing-single-element-of-list-from-apex-in-lwc
https://salesforce.stackexchange.com/questions/264631/lwc-how-to-handle-null-situation-before-the-data-is-loaded-from-controller?rq=1

Thanks