I'm trying to Get user info after a google login, i'm using passportjs, the code is working well, after the code runs I get the user data on localhost:4000/login/success as shown in the image below
But I cant fetch the data from it to show in the frontend
I'm trying this code:
const googleSignIn = async (e) => {
e.preventDefault();
dispatch({ type: "LOGIN_START" });
window.open("http://localhost:4000/auth/google/callback", "_self");
const result = await axios.get(
"http://localhost:4000/login/success",
console.log("THE INFO IS " result)
);
if (result) {
dispatch({ type: "LOGIN_SUCCESS", payload: result.data });
}
};
CodePudding user response:
Because You are console logging the data in the second param of the get request. The Second Param is the body of the request.
Instead console.log like..
const result = await axios.get(
"http://localhost:4000/login/success"
);
console.log("THE INFO IS " result)
CodePudding user response:
const result = await axios.get(
"http://localhost:4000/login/success"
);
console.log("THE INFO IS " result)