Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

155
Views
How to reduce repeated strapi api calls

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?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!