While working with VueJS, I have a handler for changes in an input field that looks like this:
inputHandler(url, params){
const p = new Promise((resolve, reject) => {
const xhr = new XMLHttpRequest();
xhr.open('POST', url, true);
...
...
});
p.then(res => this.reactiveProperty = res);
}
After sending requests in the order of 1, 2, 3, and 4, I receive responses in the order of 4, 1, 3, 2 (for example).
This results in my variable getting an incorrect value. How can I prevent this from happening?