Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

100
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda