I have a API this is working fine in console. but when I’m using map this is not working giving error.
My Code:-
function GetEgyptStates() {
const [egyptData, setEgyptData] = React.useState(null);
React.useEffect(() => {
axios.get('http://localhost:3000/states-and-districts.json').then((response) => {
setEgyptData(response.data);
console.log(response.data.Egypt.Assuit);
});
}, []);
if (!egyptData) return null;
return (
<div>
{egyptData.response.data.Egypt.Assuit.map((item) => (
<li>{item}</li>
))}
</div>
);
}
ThankYou for your Support!