我有一个使用标准handleSubmit提交的redux表单。在我的submit()
函数中,我得到了一些错误(由于我自己的逻辑),一个属性不存在。但是,此错误只是静默抑制,并且没有显示红色控制台日志,说明存在错误和其他信息。 Redux记录的简单显示了一个没有其他信息的动作redux-form/SET_SUBMIT_FAILED
。如何在此方案中获取错误日志?
<MyButton
onClick={this.props.handleSubmit(submit)}
>
List Now
</MyButton>
function submit(values) {
console.log("Submit called") // this gets logged
const url = 'store/listing/';
const options = {
method: 'POST',
}
let formData = new FormData();
const valuesAsJS = updatedValues.toJS()
Object.keys(valuesAsJS).forEach(key =>formData.append(key, valuesAsJS[key]))
let i
for (i=0; i<valuesAsJS.images.length; i++){ // error here as valuesAsJS.images is undefined
formData.append('image[]', valuesAsJS.images[i])
}
// no more logs happen whatsover and the system freezes, with
console.log("Submitting form response for listing creation")
return api_request({url, options, body: formData})
.then(response=> {
if (response.ok && response.status == 201) {
console.log("Listing creation success")
} else {
// not created show error
console.log("Erorr creating listing")
throw new SubmissionError({code: "Please re-enter or try again later", _error: true})
}
})
}