I am getting the below error enter image description here
import React ,{useState,useEffect} from 'react'; import axios from 'axios';
function DataFetching() {
const[posts,setPosts]= useState([])
useEffect(()=>{
axios.get('https://reqres.in/api/users')
.then(res=>{
console.log(res)
setPosts(res.data)
})
.catch(err=>
console.log(err) )
},[])
return (
<div>
<ul>
{
** posts.map(post=><li key={post.id}>{post.email}</li>)**
}
</ul>
</div>
);
}
export default DataFetching;
Data is successfully store in hook but map function getting an error: Posts.map is not a function
I have tried Object.values(posts).map but it is not working