Good afternoon guys. Someone can get me a doubt. I have an application node.js with a str
//index.js
var express = require('express');
var app = express();
var valor = require('./valor');
app.get('/:valor', function (req, res) {
valor.setValor(req.param.valor);
...
console.log(valor.getValor());
...
res.send(valor.getValor());
});
app.listen(3000, function () {
console.log('Example app listening on port 3000!');
});
//valor.js
let meuValor = null;
async function setValor(valor) {
meuValor = valor;
}
async function getValor() {
return meuValor;
}
module.exports = {
setValor,
getValor,
};
If I have a series of concurrent requests each will get the return sent in the request, or this value.js class it gets global in the service. and one ends up taking the other.