简体   繁体   English

每次刷新页面时调用终端命令

[英]Call terminal command every time page is refreshed

I have an app made with node.js and I need to write something like this: every time user refreshes the page, node app.js command should run in the terminal because I made data fetching in the node and if it won't be reloaded, the data won't change.我有一个用 node.js 制作的应用程序,我需要写这样的东西:每次用户刷新页面时, node app.js命令应该在终端中运行,因为我在节点中获取数据,如果它不会重新加载,数据不会改变。 I've tried to use package.json but it doesn't work.我试过使用 package.json 但它不起作用。 Is there any other way to change the data?有没有其他方法可以更改数据? Thanks in advance!提前致谢!

You don't need to run the node app.js command, again and again, it's a bad approach.您不需要一次又一次地运行node app.js命令,这是一种糟糕的方法。 Instead of this, You can simply make an API to fetch the data related to cryptocurrency and then make an API call from the frontend and render that fetched data so every time you refresh the page it will make an API call automatically and provide the latest data!取而代之的是,您可以简单地创建一个 API 来获取与加密货币相关的数据,然后从前端进行 API 调用并呈现所获取的数据,因此每次刷新页面时,它都会自动进行 API 调用并提供最新数据!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM