这是我的计时器模块。它应该在计时器代码的基础上运行代码。
我现在面临的问题是,流程工作得很好,但在设置计时器并假设在流程完成时发送的后端有点不起作用。这是因为我为计时器设置了一个值。但是,如何设置计时器以在上一个计时器/步骤完成后继续执行下一个计时器/步骤?
如果您可以在输出中看到,timer02 似乎找不到该文件。但在后台该文件仍在生成。这是计时器问题仪式吗?我们如何将其设置为当您完成时它将继续执行下一个任务。
...
app.post(('/timer02'),function(req,res)
{
res.send(serverdataTime02);
console.log(`Timer Result Main (02) :`+ serverdataTime02);
});
console.log('1.3 The Retrieved File Is Extracted To JSON Format');
console.log('...');
console.log('1.4 Proceeding to List Any File That Is Uploaded To Google Cloud Bucket...');
console.log('...');
setTimeout(() => listFiles()
.then(results =>
{
app.post(('/timer03'),function(req,res)
{
res.send(serverdataTime03);
console.log(`Timer Result Main (03) :`+ serverdataTime03);
});
...
这是代码的输出。
大家有什么想法、解决方案或链接吗?真的很感激。
最佳答案
将第一行更改为
app.post('/timer02',function(req,res) {
url 路径周围不应有任何括号。
编辑:
确保将 next() 函数调用添加到之前的路由中。 像这样的东西。
app.get('/', function(req, res, next) {
res.sendFile(path.join(__dirname, 'index.html'));
next();
})
app.get('/timer02', function(req,res, next) {
res.send(serverdataTime02);
next();
});
关于node.js - 定时器函数reactJS和NodeJS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55998047/