This is the whole code is for entering data into mysql db, whenever I try to submit the data via form the web page just keeps on loading and loading while backend receives
body-parser deprecated undefined extended: provide extended option node_modules\express\lib\router\layer.js:95:5
I followed the tutorial throughout to the end just the last part not working, in sql db i can enter data manually but just stuck here with backend post req handling,
The main issue must be comment (post handling)
//previous imports (following this tutorial https://www.youtube.com/watch?v=Mn0rdbJPWEo)
import es6Renderer from 'express-es6-template-engine';
// latest imports
import mysql, { createConnection } from "mysql";
import express from 'express';
const app = express();
import bodyParser from 'body-parser'
const encoder = bodyParser.urlencoded
// connecting to db
const Connection = mysql.createConnection({
host: "localhost",
user: "root",
password: "",
database: "nodejs"
})
// connection resposne to databse that I've created
Connection.connect(function(error){
if(error) throw error
else console.log("Korewa Korewa OWO)/ Database connected desu ne!")
})
// rendering
app.use(express.static('public'));
app.engine('html', es6Renderer);
app.set('/html/struct', 'views');
app.set('view engine', 'html');
app.get('/', function(req, res) {
res.render('struct');
});
app.get('/myacc', function(req, res) {
res.render('myacc')
});
// handing post
app.post("/",encoder, function(req,res){
let User_Email = req.body.User_Email
let Username = req.body.Username
let P_Password = req.body.P_Password
let C_password = req.body.C_password
Connection.query("select * from loginuser where User_Email = ? and Username = ? and P_Password = ?",[User_Email, Username, P_Password],
function(error, results, fields){
if(results.length > 0){
res.redirect('/welcome')
}
else if(error) throw error
else {
res.redirect("/leno")
}
res.end();
})
})
app.get("/welcome", function(req, res){
console.log("USer Signed Up")
})
app.get("/leno", function(req, res){
console.log("result lenght 0")
})
// set app port
app.listen(4000);