[Vuejs]-Json Object Not Updating In another function

0👍

Got the solution myself, thanks for your effort.

async mounted() {
        let that = this;               
        await that.getCompanyPaymentMethodLists(); 
        await that.getSalePaidDetail(); 
    },

Then in side:

methods: {  
getCompanyPaymentMethodLists: function(){
            let that = this;
            return axios.get('/api/payment_method/get_company_payment_method')
                .then((response) => {
                that.company_payment_method_lists = response.data;
                /* Generate sale_paids object */
                if(that.company_payment_method_lists){
                  var cash_payment_method_id = that.company_payment_method_lists.filter(function (payment_method) {
                        return payment_method.name == "Cash";
                  });
                  /* For Cash Payment*/                      
                  that.customer_order_details.cash_payment_method_id = cash_payment_method_id[0].id;
                } 
            })
            .catch(function (error) {
                that.errors = error;
            });
        },
getSalePaidDetail:  function(){
          let that = this;
          console.log('Heda working' + that.customer_order_details.cash_payment_method_id);

          axios.post('/api/sale_paids/get_sale_paid_history', {
              sale_id: null,
              cash_payment_method_id: that.customer_order_details.cash_payment_method_id
          })
          .then((sale_paid) => {
              that.customer_order_details.sale_paids = sale_paid.data;
          })
          .catch(function (error) {
              that.errors = error;
          });  
        },

}

Leave a comment