Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

221
Views
Promesa<IDropdownOption[]> a <IDropdownOption[]>

Tengo esta función donde obtengo el valor de los campos de mi lista spfx:

 async getFieldOptions(){ const optionDrop: IDropdownOption[]= []; const variable: IEleccion = await sp.web.lists.getByTitle("Groups").fields.getByTitle("Sector").get() let items: IListItem[] = []; variable.Choices.forEach(vari=>{ optionDrop.push({key: vari, text: vari}) }) return optionDrop }

Luego quiero obtener esos valores para insertarlos en un Dropdown html, pero obtengo un error porque mi función devuelve una promesa y las "opciones" requieren un 'IDropdownOption[]' y no sé cómo resolverlo:

 <Dropdown options={ListGroupService.getFieldOptions()} />
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Utilice useState y useEffect.

 const Component = () => { const [options, setOptions] = useState<IDropdownOption[]>(); useEffect(() => { ListGroupService.getFieldOptions().then(setOptions); }, []) if(!options){ return <>Loading...</> } <Dropdown options={options} /> }
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!