I have data in mongo. I am getting my data, but when see my console.log(). it show me data multiple times. Can you please tell me why is it happening and how to fix it?
const [teams, setTeams] = useState([])
console.log(teams)
const fetchData = async () => {
try {
const { data } = await axios('/api/getTeam/data')
setTeams(data)
} catch (error) {
console.log(error)
}
}
useEffect(() => {
fetchData()
}, [])
if I refresh page, I am getting multiple fetch. This is my output in console.log() Can you please tell me why is it happening and how to fix it? Thank you
[]
[]
[]
[]
(14) [{…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}]
(14) [{…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}]
(14) [{…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}]
(14) [{…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}]