React-redux 操作未被调度

React-redux action is not getting dispatched

我正在尝试在我的 React Next js 应用程序中使用 google 实现身份验证。我将访问令牌发送到我的后端,后端检查令牌是否有效,如果它是好的 returns header 中的令牌以访问受保护的资源。当我集成 redux 时,redux-thunk 似乎阻止了请求,请求只发送到 google 而不是我的后端。我没有收到来自后端的任何响应,我什至观察到服务器中的日志但没有请求。

此代码运行良好,它 returns 令牌

export const responseGoogle = (response) => {
    const access_token = response.accessToken;
    const tokenSend = {access_token}
        return  axios.post(`http://localhost:8000/api/auth/google/login`, tokenSend)
            .then(response => {
                console.log(response.data)
            })
            .catch(error=> console.log(error))
};

但是下面这段代码 redux-thunk 不起作用,请求也被发送到 google 但不在我的后端


export const responseGoogle = (response) => {
    const access_token = response.accessToken;
    const tokenSend = {access_token}
    return (dispatch) => {
       return  axios.post(`http://localhost:8000/api/auth/google/login`, tokenSend)
            .then(response => {
                  console.log(response.data)

            })
            .catch(error=> console.log(error))
    }
};

登录按钮

 <GoogleLogin
     clientId={config.GOOGLE_CLIENT_ID}
     buttonText="Login"
     onSuccess={responseGoogle}
     onFailure={onFailure}
     isSignedIn 
 />  

它现在正在工作,感谢 hmr 给我答案。 我只需要通过

手动触发响应
 <GoogleLogin
     clientId={config.GOOGLE_CLIENT_ID}
     buttonText="Login"
     onSuccess={response => dispatch(responseGoogle)}
     onFailure={onFailure}
     isSignedIn 
 />