Hello guys i searched a lot about it and tried everything but still I get empty body in post (The form sends body correct I just test with fiddler the node express is not getting that)!
Here is the code :
This is my Form
<form action="/user/login" method="POST">
<div class="form-group">
<label class="form-control-label">USERNAME</label>
<input type="text" class="form-control" name="username">
</div>
<div class="form-group">
<label class="form-control-label">PASSWORD</label>
<input type="password" class="form-control" name="password">
</div>
<div class="col-lg-12 loginbttm d-flex">
<div class="col-lg-6 login-btm login-text">
<p id="loginError" class="text-danger"></p>
</div>
<div class="col-lg-6 login-btm login-button">
<button type="submit" class="btn btn-outline-primary" id="loginBtn">LOGIN</button>
</div>
</div>
</form>
And this is my router and express codes:
app.use(express.json());
app.use(express.urlencoded({extended:true}));
const {loginRouter,loginRouterP} = require('./src/routes/login');
app.use('/login', loginRouter);
app.use('/user/login', loginRouterP);
And this is login Routers in other folder which I get body null:
loginRouter.get('',async(req,res) => {
res.render('login');
});
loginRouterP.post('',async(req,res) => {
console.log(req.body); // This is always {} i tried almost everything I found in stackoverflow
});
EDIT: Sorry the enctype was there by mistake I was just trying to fix