Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

148
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda