react ,使用this.props.dispatch(actions.update) 发起了一个请求,但是没有执行

问题描述

react redux ,使用this.props.dispatch(actions.update) 发起了一个请求,但是没有执行

问题出现的环境背景及自己尝试过哪些方法

界面是一个tab 切换,点击的时候在组件 componentWillMount的时候 调用了
this.props.dispatch(actions.fetchALLlevels)

控制台能打印出来 这个action,但是请求没有发送

相关代码

// 请把代码文本粘贴到下方(请勿用图片代替代码)
import { ofType } from 'redux-observable';
import { of } from 'rxjs';
import { switchMap, map, catchError } from 'rxjs/operators';
import { ajax } from 'rxjs/ajax';

import * as actions from '../actions/level';

export const fetchAllLevels = action$ =>

  action$.pipe(
    ofType(actions.fetchAllLevels),
    switchMap(() =>
      ajax({
        url: '/api/v1/rank/get',
        method: 'GET',
        headers: {
          Authorization: localStorage.getItem('token'),
        },
      }).pipe(
        map(data => {
          actions.fetchAllLevelsSuccess(data.response)}),
        catchError(err => {
          toastr.error('获取职级失败');
          return of(actions.fetchAllLevelsError(err));
        }),
      ),
    ),
  );
阅读 5.8k
1 个回答

苹果对SSL证书的要求比安卓的要严格,确认一下证书的有效性

——————————————————————
刚碰到同样问题,过来补充一波

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题