Reactjs 未捕获(承诺中)TypeError:Server.GetSecurePhase不是函数

Reactjs 未捕获(承诺中)TypeError:Server.GetSecurePhase不是函数,reactjs,axios,react-hooks,Reactjs,Axios,React Hooks,我真的需要帮助。我在connection.js中定义了一个函数,可以尝试从login.jsx调用它,但当我查看浏览器控制台时,它给出了未捕获(承诺)的类型错误:Server.getSecurePhrase不是一个函数。有人能告诉我我的代码有什么问题吗。谢谢 login.jsx import Server from "../connection/connection"; const Login = () => { const onSubmit = async (dat

我真的需要帮助。我在connection.js中定义了一个函数,可以尝试从login.jsx调用它,但当我查看浏览器控制台时,它给出了未捕获(承诺)的类型错误:Server.getSecurePhrase不是一个函数。有人能告诉我我的代码有什么问题吗。谢谢

login.jsx

import Server from "../connection/connection";

const Login = () => {

const onSubmit = async (data) => {
   console.log("data is",data)
      Server.getSecurePhrase(data).then(securePhrase => {
      setSecurePhrase(securePhrase)
   })
  }
}
这是在connection.js中

async getSecurePhrase(data) {
        console.log("Connection: getSecurePhrase");
        return axios
        .post(
          "url is here", data
          
        )
      
              .then(responseJson => {
                console.log("res: ", responseJson);
               
                return responseJson.data.security_phrase;
              })
        .catch(error => {
          console.log("Res: ", error);
          return "NULL";
        }); 
}

您如何导出GetSecurePhase?导出getSecurePhase中的默认getSecurePhase?返回等待axios.post(…)而不是返回axios.post(…)@keysl getSecurePhase放置在名为Server的功能组件中。这就是为什么我在登录时导入它。jsx@MichaelRovinsky我试过了,但没用嗯,很难看出你能添加整个服务器或者至少是最小的服务器。如果它是一个功能组件,你就不能像那样访问它