Tuesday, May 23, 2017

Vuejs v-model bind on blur to axios param

I am trying to pass input to axios param. console.log(country_id) returns country_id on blur correctly, axios country_id param is not populated, what am I missing

<div id="app">

        <input v-model="country_id" v-on:blur="addCountryId" />
        <ul>

            <li v-for="uploaded_segment in uploaded_segments"> @</li>
        </ul>
</div>

<script>
    new Vue({

    el: '#app',

    data: {

        uploaded_segments: [],
        country_id :''
    },
    methods: {

        addCountryId(){

     country_id= this.country_id;
     console.log(country_id);

}
},
    mounted() {

 axios.get('/get_segments', {
        params: {
            country_id: this.country_id
        }
    }) .then(response => this.uploaded_segments = response.data);

}
});



via dflow

Advertisement