xxxxxxxxxx
useEffect(() => {
const fetchData = async () => {
setLoading(true) // Ensure loading is true before fetching
try {
const response = await fetchSenseiDashboard()
if (response) {
//optional: should change later
const updatedRes = { //works for an array as well
engagement,
response
}
setApiResponse(updatedRes)
setActiveTab(Object.keys(updatedRes)[0])
}
} catch (error) {
console.error('Error fetching data:', error)
setError('Unable to load charts...')
} finally {
setLoading(false)
}
}
fetchData()
}, [reload])