Unable to access an array in Vue.js.
console.log(this.ref_number_response[0]);
When I try to access the array, it shows undefined. I'm puzzled by this...
data(){
return{
ref_number_response: [],
}
},
methods:{
check_ref_number: function () {
// sending axios request
axios.get('/is_referenceNumber_free/'+this.ref_number)
.then(response => this.ref_number_response.push({
info: response.data
}));
console.log(this.ref_number_response[0]);
Event.$emit('reference_added', this.ref_number_response);
},
}
<div class="form-group">
<label for="" class="col-sm-2 control-label">Ref Number</label>
<div class="col-sm-10">
<input v-model="ref_number" type="text" name="ref_number" class="form-control" id="" placeholder="Referent number" @blur="check_ref_number" required>
</div>
</div>
This is the current response I am receiving and I would like to avoid using v-for multiple times to get the actual diagnosis.
[ { "info": [ { "diagnosis": "St. post. trauma testis sin. Obs Ruptura testis sin." }, { "diagnosis": "diagnosi2" } ] } ]