[Vuejs]-Array undefined javascript

0👍

Emit the event after you recieve the data:

check_ref_number: function () {
 axios.get('/is_referenceNumber_free/'+this.ref_number)
 .then(response => Event.$emit('reference_added',[{info:response.data}]));
}

The problem is that you are getting the data asynchronously, and trying to use the data before it is ready.

0👍

You said you are trying to access the the array length, but

this.ref_number_response

is the array, so the only way this console.log(this.ref_number_response[0].info.length); is going to work ( you’re trying to get the info property from first element of the array length not the actual array length ) is if info were an array as well. So you’d probably need to do something like:

console.log(this.ref_number_response.length);

Leave a comment