I want to get a drop down but i am not getting it. The api is being called but its not being diaplayed on dropdown. I an new to react can any one rewrite the code for me.
import React,{useState} from 'react';
import axios from 'axios';
function App() {
const handleSelect=()=> {
axios
.get("https://cdndemo-api.co-vin.in/api/v2/admin/location/states")
.then((response) => {
console.log(response.data);
setState(response.data);
});
}
const [state, setState] = useState([]);
return <div>
<select onChange={handleSelect}
>
click
<option value="">Choose a user</option>
{state?.states?.map((value) => {
return (
<div>
<option value={value.state_name} key={value.state_id}>{value.state_name}</option>
</div>
);
})}
</select>
</div>;
}
export default App