So I'm using Vuelidate to validate my forms. I've tried to create my own validation helper using the plugins docs but It seems to give me "Cannot read property '__isVuelidateAsyncVm' of undefined" error when i try with the axios request. But if i just return true or if I check if the input is equal to a value "a username" it works just as intended.
I've tried to a number of things. My current attempt is: which gives me the error: Cannot read property '__isVuelidateAsyncVm' of undefined
export function isUser(value) {
if(value === "") return true;
this.$http.get('/api/user/check/'+ value).then((response) => { // this.$http = Axios.get
console.log(response.data);
return response.data; // returns true or false
})
}
This one doesn't give and error and "works" but always returns as false which forces the error to come up.
export function isUser(value) {
var isUser;
this.$http.get('/api/user/check/'+ value).then((response) => {
console.log(response.data) // returns true if value matches a username
isUser = response.data
});
console.log(isUser); // Returns undefined
return isUser ? true : false
}
I've also tried to use the lazy function. v-model.trim.lazy="$v.username.$model">
but it also didn't change anything and I would prefer it doing it on the fly without .lazy