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

94
Vistas
Get request inside afterupdate causes an infinitive loop Svelte

I am doing a get request on Svelte inside an after Update function. This creates an infinitive loop of get requests. How can I only get one request after a certain element is updated ?

For example in this case I am getting a list ,and I am using the afterUpdate because there is an option to delete lists and I want the user to see the updated list directly not after refreshing or navigating to other screens.

Or if there is another way except afterUpdate function to fulfill my purpose please let me know


 afterUpdate(async () => {
    const resp = await fetch(`__________/list`, {

    });

    if (resp.ok) {
      openlist = await resp.json();

    } else if (resp.data === "") {
      throw new Error("Could not find any company");
    }
  });```
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You could probably just use a reactive statement to trigger the fetch. E.g.

async function update() {
    // fetch here
}

// Whatever thing whose change should trigger the fetch
let someDependency;

$: someDependency, update();

(The update logic should not be inlined, otherwise the properties that are set within the function will also be tracked and you will potentially end up with a loop again.)

about 4 years ago · Juan Pablo Isaza Denunciar
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