Javascript 状态Redux未映射到道具

Javascript 状态Redux未映射到道具,javascript,reactjs,redux,react-redux,Javascript,Reactjs,Redux,React Redux,我正在努力将状态映射到React Redux中的道具。我想从RESTAPI获取数据,最后我的存储应该有两个先证者和幻灯片数组,但我没有真正得到它,为什么我的幻灯片数组是空的。这是我的档案: TestComponentRedux.js actions.js 先证者行动.js 先证者 Endpoints.js 因此,先证者数组从先证者(url)接收数据,幻灯片数组从先证者(url)接收数据 先证者数组已更新,但幻灯片数组为空 存储状态 幻灯片阵列数据 先证者阵列数据 它应该是eventslist

我正在努力将状态映射到React Redux中的道具。我想从RESTAPI获取数据,最后我的存储应该有两个先证者和幻灯片数组,但我没有真正得到它,为什么我的幻灯片数组是空的。这是我的档案:

  • TestComponentRedux.js
  • actions.js
  • 先证者行动.js
  • 先证者
  • Endpoints.js
  • 因此,先证者数组从先证者(url)接收数据,幻灯片数组从先证者(url)接收数据

    先证者数组已更新,但幻灯片数组为空

    存储状态

    幻灯片阵列数据

    先证者阵列数据

    它应该是eventslist.data。请检查下面的内容并执行aconsole.log,看看您从API中获得了哪些数据

    export const fetchProbandsWithEvents = () => {
          return async (dispatch) => {
            var probandWithEventsList = await getProbandsWithEvents();
           // Do console.log(probandWithEventsList.data) only pass the 
             information needed for payload.
            if (probandWithEventsList)
              dispatch({
                type: LOAD_PROBANDWITHEVENTS,
                payload: probandWithEventsList.data,
              });
          };
        };
    

    谢谢你的快速回答。我改为probandWithEventsList.data.slides,但我的幻灯片数组仍然是空数组:(请发送邮递员的幻灯片图像。你好,山姆,这是邮递员的幻灯片图像。[![邮递员的幻灯片图像][1]][1][1]:[![邮递员的幻灯片图像2][2][2][2]:我更新了代码,基于图像,您可以执行probandWithEventsList.data的console.log,然后查看分配负载需要传递的元素。我执行了probandWithEventsList.data的console.log以及probandList.data。但这真的很奇怪,在Web调查中,我只看到probandList.data、probandWithEventsList.dat的数据我在前端的端点中看到了很多未在后端定义的URL(Spring boot)但是它在postman中工作,你知道为什么吗?可能连接是在后端或前端的其他位置自动创建的?或者我可以在GitHub上将你添加到这个项目中吗?它是一个私人项目,所以我不允许公开发布整个代码。
    import { LOADPROBAND, LOAD_PROBANDWITHEVENTS } from "../../actions";
    
    const initialStudies = {
      probands: [],
      slides: [],
    };
    
    const probands_reducer = (state = initialStudies, action) => {
      switch (action.type) {
        case LOADPROBAND:
          return {
            ...state,
            probands: action.payload,
          };
        case LOAD_PROBANDWITHEVENTS:
          return {
            ...state,
            slides: action.payload,
          };
    
        default:
          return state;
      }
    };
    
    export default probands_reducer;
    
    
    export const LOADPROBAND = "LOADPROBAND";
    export const LOAD_PROBANDWITHEVENTS = "LOAD_PROBANDWITHEVENTS";
    
    
    import { LOADPROBAND, LOAD_PROBANDWITHEVENTS } from "../actions";
    
    import { getProbands, getProbandsWithEvents } from "../../Service/Api/Probands";
    
    import header from "../../Service/Api/Endpoints/HeaderRequest";
    
    const axios = require("axios");
    
    export const fetchProbands = () => {
      return async (dispatch) => {
        var probandList = await getProbands();
        if (probandList)
          dispatch({
            type: LOADPROBAND,
            payload: probandList.data._embedded.probands,
          });
      };
    };
    
    export const fetchProbandsWithEvents = () => {
      return async (dispatch) => {
        var probandWithEventsList = await getProbandsWithEvents();
        if (probandWithEventsList)
          dispatch({
            type: LOAD_PROBANDWITHEVENTS,
            payload: probandWithEventsList.slides,
          });
      };
    };
    
    
    import { probands_url, probands_with_events_url } from "./Endpoints/Endpoints";
    
    import header from "./Endpoints/HeaderRequest";
    
    import axios from "axios";
    
    export var getProbands = async function () {
      try {
        let res = await axios.get(probands_url, {
          headers: header,
        });
        return res;
      } catch (e) {
        return false;
      }
    };
    
    export var getProbandsWithEvents = async function () {
      try {
        let res1 = await axios.get(probands_with_events_url, {
          headers: header,
        });
        return res1;
      } catch (e) {
        return false;
      }
    };
    
    export const base_url =
      "http://" + window.location.hostname + ":" + process.env.REACT_APP_CLIENT_ID;
    
    export const sign_in = `${base_url}/auth/signin`;
    
    export const probands_url = `${base_url}/api/config/probands`;
    
    export const probands_with_events_url = `${base_url}/api/config/getAllProbandEventsProSlide`;
    
    export const fetchProbandsWithEvents = () => {
          return async (dispatch) => {
            var probandWithEventsList = await getProbandsWithEvents();
           // Do console.log(probandWithEventsList.data) only pass the 
             information needed for payload.
            if (probandWithEventsList)
              dispatch({
                type: LOAD_PROBANDWITHEVENTS,
                payload: probandWithEventsList.data,
              });
          };
        };