Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/gwt/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Reactjs 我怎样才能抓住错误?当我使用redux saga时?_Reactjs_React Native_Redux_React Redux_Redux Saga - Fatal编程技术网

Reactjs 我怎样才能抓住错误?当我使用redux saga时?

Reactjs 我怎样才能抓住错误?当我使用redux saga时?,reactjs,react-native,redux,react-redux,redux-saga,Reactjs,React Native,Redux,React Redux,Redux Saga,我怎样才能抓住错误?当我使用redux saga时? 如果const refreshresult中出现错误occred=产生调用(刷新) 我想停止并抛出此错误操作 我不知道我能做什么 yield put({ type: REFRESH_FAILURE, error: err.response.data, }); 我该怎么做?我应该如何停止并发送错误操作 这是我的密码 function getPostAPI

我怎样才能抓住错误?当我使用redux saga时? 如果const refreshresult中出现错误occred=产生调用(刷新)

我想停止并抛出此错误操作

我不知道我能做什么

         yield put({
          type: REFRESH_FAILURE,
          error: err.response.data,
        });
我该怎么做?我应该如何停止并发送错误操作

这是我的密码

        function getPostAPI(data) {
          return axiosInstace.post('/kakao/getpost', data);
        }

        function* getPost(action) {
          try {
          
            const result = yield call(getPostAPI, action.data);
            yield put({
              type: GETPOST_SUCCESS,
              data: result.data,
            });
          } catch (err) {
            if (err.response.data === 'jwtEx') {

         const refreshresult  =   yield call(refresh);  // <<<< if error occure refresh() i want to stop 

          
              yield put(action);
            } else {
              yield put({
                type: GETPOST_FAILURE,
                error: err.response.data,
              });
            }
          }
        }



        function* refresh() {
          try {
            const result = yield call(refreshAPI);
            yield AsyncStorage.setItem(
              'accesstoken',
              `${result.data.accessToken}`,
              () => {
                // console.log('accesstoken 재발급 저장 완료');
            
              },
            );
            yield put({
              type: REFRESH_SUCCESS,
              data: result.data,
            });
          } catch (err) {
          
            yield put({
              type: REFRESH_FAILURE,
              error: err.response.data,
            });
          }
        }
函数getPostAPI(数据){ 返回axiosInstace.post('/kakao/getpost',数据); } 函数*getPost(操作){ 试一试{ const result=yield调用(getPostAPI,action.data); 收益率看跌期权({ 类型:GETPOST_SUCCESS, 数据:result.data, }); }捕捉(错误){ 如果(err.response.data=='jwtEx'){
const refreshresult=yield call(refresh);//我想你的方法是对的。试着抓住就行了

查看此链接了解更多信息