Я работаю над Laravel и Vuejs, я вызываю API из своего vue js usign Axios и получаю возвращаемые данные в объекте. Но этот объект не предоставляет или не получает никаких данных о следующем методе на той же странице vue.
Моя первая функция:
getCompanyPaymentMethodLists: function(){
let that = this;
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;
});
},
И моя вторая функция: в этой функции я хочу получить свойство объекта that.customer_order_details.cash_payment_method_id, но оно дает значение null
getSalePaidDetail: function(){
let that = this;
console.log('working' + that.customer_order_details.cash_payment_method_id); // Print Null
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;
});
},
Здесь that.customer_order_details определяется как объект:
data(){
return{
customer_order_details:{
cash_payment_method_id: null,
}
}
async/await method
илиpromise
- person Karl L   schedule 06.07.2020