-2
I generate a page through:
app.get('/conteudo', (req, res) => {
res.send(conteudojson);
}).
Dynamically, the conteudojson
is amended and listed again the "/content":
app.get('/conteudo', (req, res) => {
res.send(conteudojson);
}).
However, when accessing "/content", it is shown only the first interface generated and not the changed one conteudojson
.
Only after I stop the server with CTRL+C and restart the server that changes the conteudojson
is listed under "/content".
Below the code:
const editarIndicador = (dados, app) => {
let key = dados.chave
console.log('Dentro de Edição')
firebird.attach(optionsInd, function(err, db) {
var optionsIndicador = {
"chart": {
"title": `${dados.editarTitulo}`,
"subtitle": `${dados.editarSubtitulo}`
},
"width": dados.editarLargura,
"height": dados.editarAltura }
let opcoes = JSON.stringify(optionsIndicador)
if (err) {
throw err;
console.log('Erro:', err)
}
let SQL = `update
TBL_INDICADORES
set DESC_INDICADOR ='${dados.editarDescInd}' ,
MODELO ='${dados.editarModeloIndicador}',
BUSCARDADOS ='${dados.editarDados}',
OPTIONSIND ='${opcoes}'
where KEY = ${key}`
console.log('SQL: ', SQL)
db.query(SQL, null, function(err, result) {
db.query(`SELECT * FROM TBL_INDICADORES WHERE KEY=${key}`, function(err, result) {
console.log('Ultimo registro Alterado', result);
function fx(v) { return v }
app.get('/indicadores', (req, res) => {
res.send(result);
})
db.detach();
});
});
});
return true
}
In the console, it is shown that the contents passed by SQL.
However, with res.send(result)
does not release the new content in "/indicators", which has the contents of the first listing.
Below the code:
const editarIndicador = (dados, app) => {
let key = dados.chave
console.log('Dentro de Edição')
firebird.attach(optionsInd, function(err, db) {
var optionsIndicador = {
"chart": {
"title": `${dados.editarTitulo}`,
"subtitle": `${dados.editarSubtitulo}`
},
"width": dados.editarLargura,
"height": dados.editarAltura }
let opcoes = JSON.stringify(optionsIndicador)
if (err) {
throw err;
console.log('Erro:', err)
}
let SQL = `update
TBL_INDICADORES
set DESC_INDICADOR ='${dados.editarDescInd}' ,
MODELO ='${dados.editarModeloIndicador}',
BUSCARDADOS ='${dados.editarDados}',
OPTIONSIND ='${opcoes}'
where KEY = ${key}`
console.log('SQL: ', SQL)
db.query(SQL, null, function(err, result) {
db.query(`SELECT * FROM TBL_INDICADORES WHERE KEY=${key}`, function(err, result) {
console.log('Ultimo registro Alterado', result);
function fx(v) { return v }
app.get('/indicadores', (req, res) => {
res.send(result);
})
db.detach();
});
});
});
return true
}
Only with this code you posted can you help.
– LeAndrade
I understand Leandrade. I will post all the code below. But my doubt is when I use nodejs with expression and launch a res.send() there is how to override what was generated by send()?
– Wanderson Moreira
Friend because your question is too vague, I think the effect Voce wants is that when Voce changes its file the server also change in the url, for that Voce can use the tool nodemon. Just follow the documentation and every time your system has changed the files the server will be reloaded.
– Higor Alves
you are using a function, need to give the Return, is not that?
– Juliano Henrique
No need to Return. It arrow in the app the route. when use
app.get('/indicadores', (req, res) => { 
 res.send(result);
 })
´– Wanderson Moreira
Dude it’s really weird your code to tell you the truth, you get the updated json from where? And when it does res.send(conteudojson) you simply play on the screen the json, is not giving to understand.
– LeAndrade