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.

4
  • Can you provide more context? Question is unclear Commented Jul 2, 2020 at 5:16
  • take a look at this : stackoverflow.com/questions/31413053/… Commented Jul 2, 2020 at 5: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. Commented Jul 2, 2020 at 5:59
  • edited the question with code Commented Jul 3, 2020 at 5:29

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.