title: Redirect after Post method , expressjs
body: <p>I'm learing ExpressJS, and so far I did the user registration part but when I want to redirect to the home page after finishing the registration, it's not
  showing the json after clicking on Submit button. May I know how I could do it. </p>
  
  <p><strong>Database</strong></p>
  
  <pre><code> var mysql = require('mysql');
  
      var con = mysql.createConnection({
        host: "localhost",
        user: "root",
        password: "",
        database:'reciepeapp'
      });
  
      module.exports  = con
          the ORM
  
  
  
  const con = require('./db')
  </code></pre>
  
  <p><strong>The ORM</strong></p>
  
  <pre><code>        const orm = {
  
            insertOne: function (values, cb) {
  
       const sqlQuery = "INSERT INTO authentication(username,password)  VALUES ?";
          con.query(sqlQuery, [values],function (err, data) {
            if (err) {
              console.log(err)
              cb(err, null);
            } else {
              cb(null, data);
            }
        });
          },
  
  
          }
          module.exports = orm;
  </code></pre>
  
  <p><strong>The route.js</strong></p>
  
  <p>Here I insert the data obtained during registration (register index html) into a database. It's working well but I want to redirect to home page.</p>
  
  <pre><code>    const express = require('express');
              const app = express()
              const router = express.Router()
              const bcrypt = require('bcrypt');
              bodyParser = require('body-parser');
              app.use(bodyParser.urlencoded({ extended: true }));
  
              const orm = require('../models/orm')
              router.get('/',(req,res)=&gt;
                  res.render('home')
              )
              router.get('/login',(req,res)=&gt;
                  res.render('login')
              )
              router.get('/register',(req,res)=&gt;
                  res.render('register')
              )
             router.post("/register",  async (req, res) =&gt;{
          try {
              const hashedPassword = await bcrypt.hash(req.body.password,10)
              values = { username: req.body.name,
                  password:hashedPassword  } 
  
  
             orm.insertOne(values, function(error) {
  
                 if (error) {
                     return res.status(401).json({
                         message: 'Not able to add'
                     });
                 }
                 values = { username: values.username,
                  password: values.password } 
  
  
             orm.insertOne(values, function(error) {
  
                 if (error) {
                     return res.status(401).json({
                         message: 'Not able to add'
                     });
                 }
                 **return res.send({
                     username: values.username,
                     password: values.password
                 });**
  
             });
  
             });
  
          }
  
      catch {
  
      }
      });
          module.exports = router
  
  
  
  
  
  
       const express = require('express');
          const app = express()
          const bodyParser = require("body-parser");
          const indexRouter = require('./routes/route')
          const con = require('./models/db')
          con.connect(function(err) {
              if (err) {
                return console.error('error: ' + err.message);
              }
  
              console.log('Connected to the MySQL server.');
            });
            app.use(bodyParser.urlencoded({ extended: false }));
            app.use(bodyParser.json());
          var exphbs  = require('express-handlebars');
          console.log(__dirname)
          app.use('/',express.static(__dirname + '/public'));
          app.engine('handlebars', exphbs());
          app.set('view engine', 'handlebars');
          app.use('/',indexRouter)
          const PORT = 5000;
          app.listen(PORT,()=&gt;console.log('it started on 5000'))
  </code></pre>