Redux-saga调用效果访问状态代码

时间:2018-03-22 12:09:10

标签: javascript reactjs redux redux-saga

在玩redux-saga时,注意到发生错误时的调用效果传递给catch子句只是错误的文本。我如何访问响应状态代码?例如,如果状态代码为401,我会抓住,我想在那里实现一些逻辑。

例如:

try {
    const response = yield call(fetch, uri, options);
    //some more logic to dispatch eventual success response
  } catch (error) {
    console.error('Error:', error);
    //here is only printed ie 'Error: TypeError: Failed to fetch' but i need to access as well status code here
  }

0 个答案:

没有答案