【发布时间】:2017-06-07 00:04:59
【问题描述】:
我一直在处理我的 react-native/redux 应用程序中包含错误的对象数组。
我有一个看起来像这样的 handleResponse 函数:
function handleResponse (response) {
let status = JSON.stringify(response.data.Status)
let res = JSON.stringify(response)
if (Number(status) === 200) {
return res
} else {
throw new SubmissionError('Something happened')
}
}
但不是将纯文本作为参数传递给 SubmissionError 函数 - 我想以某种方式从对象数组中取出错误。
包含错误消息的对象数组如下所示:
{
ErrorMessages: [
{ ErrorMessage: 'foo' },
{ ErrorMessage: 'bar' }
]
}
例如,我怎样才能抛出 foo 和 bar 错误?
【问题讨论】:
标签: arrays react-native redux react-redux redux-form