maxkordiyak / react-native-dropdown-autocomplete

Autocomplete input with dropdown modal component for React native. Useful for pages with multiple autocomplete's.
MIT License
100 stars 51 forks source link

selection of item #24

Open johanavasq opened 5 years ago

johanavasq commented 5 years ago

How could I do that when I click and select a card with another api I automatically load the name, surname, telephone data.

<Autocomplete
   key={shortid.generate()}
   style={baseStyles.input}
   scrollToInput={ev => { }}
   handleSelectItem={(item, index) => {}}
   onDropdownClose={() => { }}
   onDropdownShow={() => { }}
   minimumCharactersCount={1}
   highlightText
   valueExtractor={item => item.cedula) }
   rightContent
   rightTextExtractor={item => item.properties}
   placeholder="cedula"
   fetchData={async (cedula) => {
       const response = await fetch(`https://www.basedx.com/api/buscarcedula? 
       ced=${cedula}`);
       return await response.json();
     }
/>

Captura de Pantalla 2019-08-23 a la(s) 9 44 42 a  m Captura de Pantalla 2019-08-23 a la(s) 9 44 25 a  m

how can I pass the other api so that by selecting I fill in the fields. api

    fetchData={async (cedula) => {
                        const response = await fetch(`https://www.basedx.com/api/usercedula? 
                        user=${cedula}`);
           var dataCed = await response.json();
            return dataCed.map(x => { (item.first_name || item.las_tname || item.telefono) });

example the api returns me

{
  user: {
    first_name: "carmen",
    last_name: "montoya",
    telefono: 0
  },
  success: true