Answer the question
In order to leave comments, you need to log in
Is it possible to load new data from the database to node.js without restarting the server?
let messages; // получаю список из базы
knex.select().from('messages').timeout(1000).then(res => {
messages = JSON.stringify(res);
});
router.get('/api', async (ctx, next) => {
ctx.body = messages; // вывожу
});
Answer the question
In order to leave comments, you need to log in
There's nothing to just write code through the ass. Your data is received once, but you need to do the receiving inside the corresponding method, at least (I’ll omit about SOLID, etc. for now)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question