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

213
Visualizações
How to receive only value from the last request?

In VueJS, I have handler of an input field changes, as below:

inputHandler(url, params){                    
  const p = new Promise((resolve, reject) => {
    const xhr = new XMLHttpRequest();
    xhr.open('POST', url, true);
    ...
    ...
  });
  p.then(res => this.reactiveProperty = res);
}

So, I gain response and put it into a reactive variable. I send requests at order 1, 2, 3, 4, but receive responses in order 4, 1, 3, 2 (for example).

This is a reason, that the variable gets incorrect value. How could avoid it?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You can use async, await. It will wait the first promise then gets to the second, second then third...etc. Also like @T.J. Crowder said, you should use the fetch api instead.

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