When I did a console.log(response.data), it returned 2 datasets namely post and user:
const [dbdata,setDBData] = useState([])
useEffect(async() => {
const response = await Axios.get('http://localhost:5000/api/posts/allpost', {withCredentials:true})
setDBData(response.data)
console.log(response.data)
}, [])
{post: Array(2), user: Array(1)}
post: (2) [{…}, {…}]
user: [{…}]
So when I tried dbdata.post.map(), it says map() is a not function. What I am missing here? Many thanks in advance and greatly appreciated.
response.data.dbdata.post.map()is not present in the code you shared.