In my app.js file, I have and app.post and it is firing all of the functions I am calling every time a post request goes through. How do I set this up to not fire all of them every time?
app.post('/ownerPanel', (req, res) => {
 if(books.books.addBookOwner(req.body.book_title,req.body.author, 
    req.body.price,req.body.subject,req.body.isbn, req.body.Vendor, 
    req.body.Owner, connection, res)){
    console.log("in the if in app vendor");
    books.books.renderOwner(connection, res);
   }
else if(books.books.deleteBook(req.body.isbn,connection, res)){
  console.log("in the if in app post ");
  books.books.renderOwner(connection, res);
    }
    books.books.renderOwner(connection, res);
})
It isn't going into any of my if statements either because the console log never shows.
 renderOwner : function(connection, res){
   var out = []
  var query = connection.query('SELECT * FROM book_table WHERE Owner = "test"',function(err,rows){
   if(err)
    console.log("Error Selecting : %s ",err );
   for(var i = 0; i< rows.length; i++){
      var row = rows[i];
      out.push(row[i]);
      }
    res.render('../views/ownerPannel', {book_data : rows}) 
    });
  },
addBookOwner : function(book_title, author, price, subject, isbn, Vendor, Owner, connection, res) {
         sql = "INSERT INTO book_table (book_title,author,price,subject,isbn,Vendor,Owner) VALUES ('" + book_title+ "','" + author + "','" + price + "','" + subject + "','" + isbn +"','" + Vendor +"','" + Owner +"')";
  account = connection.query(sql, function (err, result) {
  if (err){ console.log(err);
     throw err;}
    return result
   });
  },
 deleteBook : function(isbn, connection, res){
  connection.query('DELETE FROM book_table WHERE isbn = ?', isbn , (err, result) => {
  if (err) {
    console.log(err);
   } else {
  console.log("deleted");
      }
    });
 }
};
 
    