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

217
Vistas
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 Respuestas
Responde la pregunta

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 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