0

In REACT, I am fetching data from an API and want to present key field from that in a drop down menu for user to select one of the values. API returns an array and has a key field.

//get data api - Global data 
const [globalData, setGlobalData] = useState(); 
const [dataLoading, setDataLoading] = useState(false); 

useEffect(() => { async function fetchGlobalData()
 { setDataLoading(true) 
const url = "api.thevirustracker.com/free-api?global=stats"; 
const apiResponse = await fetch(url) 
const dataFromAPI = await apiResponse.json() 

... 

How can I build a drop down list from one of the key fields of the array.

nktoronto
  • 711
  • 1
  • 7
  • 10
  • Can you provide more context? Question is unclear – Mohit Jul 02 '20 at 05:16
  • take a look at this : https://stackoverflow.com/questions/31413053/how-to-use-an-array-as-option-for-react-select-component – KALITA Jul 02 '20 at 05:55
  • You can edit your question if you want to add code, it will be easier to read. But, I would also recommend you add show what you tried so far and explain why it didn't work/where you got stuck. – Evert Jul 02 '20 at 05:59
  • edited the question with code – nktoronto Jul 03 '20 at 05:29

0 Answers0