Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

209
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!