Server Site
Getting Email query from server site, It's not connecting to my client site But it's working on my server site
app.get('/login', async (req, res) => {
const user = req.body;
const accessToken = jwt.sign(user, process.env.ACCESS_TOKEN_SECRET, {
expiresIn: '1d'
});
res.send({ accessToken });
});
Client Ste Login Function Part
This is my client site login part functional and callback part, There my email is showing in console but doesn't work in server which I show in picture.
import axios from 'axios';
import React from 'react';
import { useAuthState, useSignInWithEmailAndPassword } from 'react-firebase-hooks/auth';
import GoogleButton from 'react-google-button';
import { Link, useLocation, useNavigate } from 'react-router-dom';
import auth from '../Firebase.init';
const Login = () => {
const navigate = useNavigate();
const [signInWithEmailAndPassword, loading, error] = useSignInWithEmailAndPassword(auth);
const [user] = useAuthState(auth);
if (user) {
navigate('/');
}
const handleLogin = async e => {
alert('ok');
e.preventDefault();
const email = e.target.email.value;
const password = e.target.password.value;
await signInWithEmailAndPassword(email, password);
const { data } = await axios.post('http://localhost:5000/login', { email })
console.log(data);
console.log(email);
};
}