I am new to React with node Now I want to send data from node js(backend) to React js with response data. Actually, my situation is after signup from Google authentication I want to send that data to a React js (frontend).
router.get(
'/auth/google/callback',
passportGoogle.authenticate('google', {
failureRedirect: '/',
}),
(req, res) => {
const nameFirst = req.user.profile._json.displayName;
const picture = req.user.profile._json.image.url;
const email = req.user.profile.emails[0].value;
const id = req.user.profile.id;
const user = new User({
user_token: id,
name: nameFirst,
email: email,
picture: picture,
provider: 'Google',
dateSent: Date.now(),
});
User.findOne({ email: email }, (err, docs) => {
if (docs != null) {
// already exist
} else {
// send data `user` with routing [routing to /signupnext,]
}
});