Не удается прочитать ошибку ответа HTTP-запроса - PullRequest
0 голосов
/ 01 ноября 2018

В настоящее время я использую избыточные циклы в своем родном приложении React для выполнения запроса 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

В чем проблема?

Заранее спасибо

...