So my first res.send command works but after making queries I cant get them to work. Not sure what to do. The console.log works like a charm for each if statement but the res.send is being really finnicky.
app.get('/info', function(req,res) {
var option1 = req.query.option1
var option2 = req.query.option2
var option3 = req.query.option3
if (option1 == 'SELECT' || option2 == 'SELECT' || option3 == 'SELECT') {
res.send('Please select all valid fields and try again');
console.log('Not all fields were filled out');
}
if (option3 == 'Cash') {
var queryCash = connection.query('SELECT toll FROM tollschedule.cashtollschedule WHERE interchangeEnter=' + option1 + ' AND interchangeExit=' + option2);
var formatCash = queryCash[0].toll;
var answerCash = '$' + parseFloat(formatCash).toFixed(2);
res.send('Cash');
console.log(queryCash);
console.log('Toll request received from ' + option1 + ' to ' + option2 + ' costing ' + answerCash);
}
if (option3 == 'E-ZPass') {
var queryEz = connection.query('SELECT toll FROM tollschedule.ezpasstollschedule WHERE interchangeEnter=' + option1 + ' AND interchangeExit=' + option2);
var formatEz = queryEz[0].toll;
var answerEz = '$' + parseFloat(formatEz).toFixed(2);
res.send('EZ');
console.log(queryEz);
console.log('Toll request received from ' + option1 + ' to ' + option2 + ' costing ' + answerEz);
}
})