无法读取http请求响应的错误

时间:2018-10-31 22:28:06

标签: react-native redux react-redux cycle xstream

我目前在我的React本机应用程序中使用redux-cycles来发出API请求。这是我的周期:

const handleAction$ = ACTION
.filter(({ type }) => type === Types.MY_THING)
.map(({ stuff }) => stuff)
.compose(fooBar())
.map(() => ({
  url: 'bad_url_for_testing',
  method: 'POST',
}))

const continue$ = HTTP
  .select('sendStuff')
  // check for error
  .map(response$ => response$.replaceError(err => xs.of(err.response)))
  .flatten()
  // choose the correct action
  // this is where it fails!
  .map((res) =>
    res.error
    ? Creators.failureAction()
    : Creators.successAction()
  );
return {
  HTTP: handleAction$,
  ACTION: continue$
}

但是,在运行周期时,我将收到以下错误:

Cannot read property 'error' of undefined

出了什么问题?

预先感谢

0 个答案:

没有答案