I have an express application, my route file has the following code:
java.ejs
var express = require('express');
var router = express.Router();
var handle_database = require('../db');
var drvArray = [];
router.get('/', function (req, res, next) {
var query = "SELECT qte FROM drivers";
handle_database(query, true, function (resp) {
drvArray.push({
"drivers" : resp
});
res.render('java', {
drivers : JSON.stringify(drvArray[0])
});
});
});
When I run my server and go to the view file java.js that has this code :
<%= drivers %>
I get this output : {"drivers":[{"qte":"2000"}]}
and the output in the console is : GET /java 200 50.030 ms - 982.
Now when I edit the entry in my database and make it 3000 I get in the view the old result 2000 and not 3000 and the output in console is :
GET /java 304 8.562 ms - -
If I restart the server I get the new correct value 3000 but 200 as header.
So how can I deal with that and have always the correct value displayed?