I want to check the availability of a username in a database querying to an API. The code related to the rule that evaluate the field is:
extend('exists', value => {
apiService.checkUsername(value)
.then(response => {
response.data[0].username == value?true:false;
})
.catch(response => alert(response.message));
}, {
immediate: false
})
My problem is: the error message is shown before the API's response. I wanna show it after the response. Any idea?