I'm trying to add a checkbox to a webpage with react. its value is in useWalletCreadit. after that, by submitting the form it should post it to api.py file. this is post method:
submitForm: (pay_method, useWalletCredit, onSuccess, onFailure) => {
console.log(this.useWalletCredit);
dispatch({type: 'START_LOADING'});
return PrivateApi.post('cart/pay', {
'submit-pay': 'submit',
web: 'true',
'pay-method': pay_method,
'useWalletCredit_': this.useWalletCredit,
})
.then(res => {
dispatch({type: 'END_LOADING'});
if (onSuccess) onSuccess(res.data);
}).catch(error => {
dispatch({type: 'END_LOADING'});
if (onFailure) onFailure(error);
})
},
it raise this error:
CartPay.js:532 Uncaught TypeError: Cannot read property 'useWalletCredit' of undefined