I have the following code
const getData = async (): Promise<void> => {
const { page, pageSize } = pageOption
try {
setShowContentLoader(true)
const { data: isActiveData } = await axiosStrapi.get('/changelog-sellers?isActive=true&_sort=id:DESC')
const { data: pageOptionRows } = await axiosStrapi.get(`/changelog-sellers?_start=${(page - 1) * pageSize}&_limit=${pageSize}&_sort=id:DESC`)
const { data: rows } = await axiosStrapi.get(`/changelog-sellers?type=${type}&_start=${(page - 1) * pageSize}&_limit=${pageSize}&_sort=id:DESC`)
const { data: oldRows } = await axiosStrapi.get('/changelog-sellers?_start=0&_limit=10&_sort=id:DESC')
setFeaturedPosts(isActiveData.slice(0, 3))
setOldChangelogSellers(oldRows)
if (type === 'all') {
const { data: count } = await axiosStrapi.get('/changelog-sellers/count')
setTotal(count)
setChangelogSellers(pageOptionRows)
} else {
const { data: tabTitleCount } = await axiosStrapi.get(`/changelog-sellers/count?type=${type}`)
setTotal(tabTitleCount)
setChangelogSellers(rows)
}
} catch (error) {
console.log('error', error)
} finally {
setShowContentLoader(false)
}
}
I am repeatedly calling /changelog-sellers to get different kinds of data. Is there a way to simplify my code so that I only call /changelog-sellers once? Or is it impossible because I need to pass different parameters to each of the different api call even though they are all sourced from /changelog-sellers?