Axios not sending body to my API.
router.get('/login', async function(req,res) {
try {
const email = req.body.email;
const pass = req.body.pass;
const users = await pool.query("select username from users where username=$1 and password=$2", [email, pass]);
if(users.rows[0])
res.json(users.rows[0]['username']!=null);
else
res.json(users)
console.log(req.body)
console.log(email,pass)
} catch (err) {
console.log(err.message);
}
});
When I console.log the req.body it after running GetData
async function GetData() {
const email = document.getElementById("email").value;
const pass = document.getElementById("pass").value;
const response = await axios.get("http://localhost:3002/login",
{
body: JSON.stringify({"email": email, "pass" : pass})
})
console.log(response.config.body);
console.log(response.data.rows)
}
The body is said to be {} an empty object.
How do I send the body through axios the same way insomnia is sending a body.
When using insomnia and the exact same body it returns true as it should.