Reactjs Redux:TypeError:无法读取未定义的属性“prototype”

Reactjs Redux:TypeError:无法读取未定义的属性“prototype”,reactjs,redux,Reactjs,Redux,我遵循本教程,一步一步地建立一个mern网站。一切都很顺利,直到Profile Reducer&获得当前的Profile。我添加了actions/profile.js和reducers/profile.js等,得到了以下错误 我想我的代码和视频教的一样。有人知道可能是什么问题吗 减速器/profile.js: import { GET_PROFILE, PROFILE_ERROR } from "../actions/types"; const initialState =

我遵循本教程,一步一步地建立一个mern网站。一切都很顺利,直到Profile Reducer&获得当前的Profile。我添加了actions/profile.js和reducers/profile.js等,得到了以下错误

我想我的代码和视频教的一样。有人知道可能是什么问题吗

减速器/profile.js:

import {
    GET_PROFILE,
    PROFILE_ERROR
  } from "../actions/types";

const initialState = {
  profile: null,
  profiles: [],
  repos: [],
  loading: true,
  error: {}
};

export default function(state = initialState, action) {
  const { type, payload } = action;

  switch (type) {
    case GET_PROFILE:
      return {
        ...state,
        profile: payload,
        loading: false
      };
    case PROFILE_ERROR:
      return {
        ...state,
        error: payload,
        loading: false
      };
    default: 
      return state
  }
}
actions/profile.js

import axios from "axios";
import { setAlert } from "./alert";

import { GET_PROFILE, PROFILE_ERROR } from "./types";
import { response } from "express";

// Get current users profile
export const getCurrentProfile = () => async dispatch => {
  try {
    const res = await axios.get("/api/profile/me");

    dispatch({
      type: GET_PROFILE,
      payload: res.data
    });
  } catch (err) {
    dispatch({
      type: PROFILE_ERROR,
      payload: { msg: err.response.statusText, status: err.response.status }
    });
  }
};
Dashboard.js:

import React, { useEffect } from "react";
import PropTypes from "prop-types";
import { connect } from "react-redux";
import { getCurrentProfile } from "../../actions/profile";

const Dashboard = ({ getCurrentProfile, auth, profile }) => {
  useEffect(() => {
    getCurrentProfile();
  }, []);

  return <div>Dashboard</div>;
};

Dashboard.propTypes = {
  getCurrentProfile: PropTypes.func.isRequired,
  auth: PropTypes.object.isRequired,
  profile: PropTypes.object.isRequired
};

const mapStateToProps = state => ({
  auth: state.auth,
  profile: state.profile
});

export default connect(mapStateToProps, { getCurrentProfile })(Dashboard);

从屏幕截图中的堆栈跟踪判断,问题似乎与express软件包有关

从作为问题一部分提交的代码片段中,只有文件:actions/profile.js包含与express相关的任何代码。它包含以下导入语句:

import { response } from "express";

我看不出您在哪里使用响应,所以我假设您不需要它-这就是您在删除该行代码后在评论中承认问题的原因。

我们不知道本课程使用的代码。请将相关内容粘贴到此处,以便我们可以帮助调试该问题。Well,该项目相当大,有很多文件。好的,但我希望您能够理解,我们无法通过猜测代码的外观来帮助解决问题。您需要从express导入{response};?您似乎没有在actions/profile.js中使用它。堆栈跟踪似乎从express包引发了一个错误。你试过一步一步地调试它吗?你能添加一个答案让我接受吗?