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

203
Views
ReactJS: React-Select to call api and filter result

I'm creating a search box where you can write some letters and the api should gives back a list filtered. Now my problem is that this list is empty (but the value that should be display is found)

<AvGroup>
                  <Label id="comCodLabel" for="sce-persona-comCod">
                    <Trans i18nKey="sce_persona.comCod">{'sce_persona.comCod'}</Trans> {'*'}
                  </Label>
                  <Async
                    options={listaValoriTrovati}
                    value={comCod}
                    loadOptions={getComuniNome.bind(this)}
                    onChange={onChangeComuni}
                  // getOptionLabel={options => options['label']}
                  // getOptionValue={options => options['value']}
                  />
                </AvGroup>

const [listaValoriTrovati, setListaValoriTrovati] = useState([])

  const getComuniNome = (searchTerm) => {
    console.log("searchTerm ", searchTerm)
    return axios.get(`${apiComuni}?comDes.contains=${searchTerm}`)
      .then(res => {
        console.log("res ", res.data)
        setListaValoriTrovati(res.data.map(val => { return ({ value: val.comCod, label: val.comDes }) }))
      })
  }

  console.log("listaValoriTrovati ", listaValoriTrovati)

this listaValoriTrovati console.log me an array of object [{value: 'value', label: 'label'}]

But the list displayed is empty and doesn't show the label.

In your opinion how can I do?

Thank you.

about 4 years ago · Juan Pablo Isaza
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!