[Vuejs]-My Vue.js code is not working while loading

0👍

Hi you need to add var to check if data is loaded or on progress.

  loadCustomers : function(){
            let uri = this.rootUrl + '/load_customer/' ;
            alert(uri);

            loaded: false;

            axios.get(uri)
            .then(response => {
                //if(response.data == 'success'){
                this.customers = response.data['customers']  ;
                loaded: true;

                //alert(this.customers);
                //} 
            })
            .catch(function (error) {
                console.log(error.response);
            });
        },

and in your view

     @if(loaded){
     {{--  @foreach($customers as $customer)--}}
                <tr id="customerTable"  role="row" class="odd"   v-for="customer in customers">
                  <td class="sorting_1">@{{ customer.company }}{{-- $customer->company --}}</td>
                  <td class="">{{-- $customer->address --}}</td>
                  <td>{{-- $customer->contact --}}</td>
                  <td>{{-- $customer->contact_person --}}</td>
                  <td>{{-- $customer->contact_person_phone --}}</td>
                </tr>
                {{--  @endforeach --}}
}
              </tbody>

Leave a comment