I am currently trying to use an API. From what I tested in postman, the server got internal error (status: 500) if I send voucher_id with data that is not recognized (it only accept 1 & 2, the rest is not acceptable). If I remove voucher_id in the postman, the code works properly (from what I see, it has no problem if no voucher_id. The API gives different response compared to when it has voucher_id). So I want to make if to check whether I can remove voucher_id or not.
<TouchableOpacity
onPress={() => {
dispatch(
PaymentAssesment({
project_id: params.id,
name: params.name,
voucher_id: disc ? disc.id : '',
}),
);
}}>
<Text style={styles.itemButton}>Lanjutkan</Text>
</TouchableOpacity>
This is the code I got and I wonder how to change this to make if to either include voucher_id or just remove it