nanakumi75 16 Newbie Poster

I hope someone can understand my question and offer some help. I am creating a Flight Booking application with Amadeus APIs. I have a flight search form on the index page with hbs template engine.

The form submits to /auth/flights for processing. I then want to display all error in index page (if there are any).

But the problem is that, maybe due wrong linking, I can't get the form to display all errors back to the index page. I will display my code below so that you can see what I mean.

//flight search form in index.hbs

    <form action="/auth/flights" method="post">
      input details here

//in server.js

//auth.js @ routes/auth
const express = require('express');
const router = express.Router();
const authController = require('../controllers/auth');'/',;
module.exports = router;

//in auth.js @ controllers/auth = function(req,res){
  const {location,destination,depart} = req.body;

  if(!location || !destination || !depart){
  res.status(404).render('/',{error:'Fields marked are required'});

My problem is that, I can't reload the index page. I will be happy if someone can offer some advice

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.