- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
关注这个 youtube video了解 node.js
我遇到了这个错误
$ nodemon index.js
(node:18129) [DEP0096] DeprecationWarning: timers.unenroll() is deprecated. Please use clearTimeout instead.
应用服务器仍然可以运行。但是,当我尝试添加路由器以将项目添加为视频时,它从未成功通过。但是,我会称之为半成功,因为我确实在终端中看到了数据日志,但再也没有返回到数据库。如您所见,在我查询之后,我们可以在终端中看到 xxx as name as 40 as price
http://localhost:4000/products/add?name=xxx&price=40
在 10:52 左右的浏览器中,如视频中所示。 (我在 index.js 文件中进行硬编码后让它工作。为什么我不能像视频那样查询它?)我假设 timers.unenorll() 导致了这个。但我用谷歌搜索了一下,我只找到了这个 one ,还有这个 one (在 https://nodejs.org/en/blog/release/v10.0.0/ 页面上)
但是不知道怎么办。找不到解决方案。请帮忙
$ node -v
v10.0.0
const express = require('express');
const cors = require('cors');
const mysql = require('mysql');
const app = express();
app.use(cors());
const SELECT_ALL_PRODUCT_QUERY = 'SELECT * FROM products';
const connection = mysql.createConnection({
host: 'localhost',
user: 'genius',
password: 'genius',
database: 'react_sql'
});
connection.connect(err => {
if(err) {
return err;
}
});
console.log(connection);
app.get('/',(req, res) => {
res.send('go to /products to see the genius gyms')
});
app.get('/products/add', (req, res) => {
const {name, price} = req.query;
//console.log(name, price);
const INSERT_PRODUCTS_QUERY = `INSERT INTO products(name, price) VALUES('${name}',${price})`;
connection.query(INSERT_PRODUCTS_QUERY,(err, results) => {
if(err) {
return res.send(err)
} else {
return res.send('successfully added product')
}
});
});
app.get('/products', (req, res) => {
connection.query(SELECT_ALL_PRODUCT_QUERY,(err,results) => {
if(err) {
return res.send(err)
}
else {
return res.json({
data: results
})
}
});
});
app.listen(4000,() => {
console.log(`Genius gyms listening on
port 4000`)
});
最佳答案
npm install mysql@2.16.0 --save
只需将 mysql 库更新到最新版本。
关于node.js - DeprecationWarning : timers. unenroll() 已弃用。请改用 clearTimeout,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50072849/
如何清除浏览器中另一个选项卡中设置的超时? 我尝试在 localStorage 中存储超时引用,但无法清除timeout function setIdleTimeout() { var idl
我正在为我的代码寻找解决方案。我的clearTimeout 函数在stop() 中不起作用;和开始();功能,有人知道如何解决这个问题吗? 停止、启动、复位按钮都有setTimeout功能。我想做的是
这是一个JSFiddle问题的示例。 当我单击按钮时,所有内容都会按预期淡出并在 3 秒内返回或直到单击为止。但是,如果我不等待 3 秒,而是提前单击它,然后快速单击按钮,它会在 3 秒内返回。 编辑
我有一个带有子菜单的菜单,当您单击按钮时,该子菜单会滑出。我希望它在 7 秒后滑回(如果尚未重新单击)。我想在重新单击时重置计时器,以便在再次单击时从头开始。 $(".connect").cl
这些是相关的行。 // In the parent page I set the timer and attach its handle to the window window.warnTo = w
好吧,我在users.js.coffee中有一些coffeescript,它在滚动用户名时运行twitter Bootstrap 弹出窗口(当前正在工作)现在我想要做的是使用超时来隐藏弹出窗口,如果用
假设我有一个运行客户端的函数render,可能需要 100-1000 毫秒我有一个函数fetch,它发出服务器请求,并在成功时清除渲染超时,然后以 100 毫秒的超时调用渲染。我有一个按钮,oncli
我有一个动态更新的计时器。 ----------------更新------------------------当我第一次发布问题时,我认为从主干 View 中调用计时器并不重要,但我相信因此,我不能
Javascript 滑动菜单保持打开状态。 clearTimeout 没有按预期工作 - 你能帮帮我吗 #Menu1 {position:absolute; top:-190px; left
我正在处理一个模板文件,并且有 3 个列表项,当您滚动鼠标时会为每个加载隐藏的 div 突出显示文本,使其可见。在鼠标移出时,在 div 再次隐藏之前设置延迟。 clearTimeout 适用于用户是
当我尝试 clearTimeout() 时,超时只是继续。代码: function autoSlides(x) { var timeOut; if (x == 1) {
我有一个警告消息栏,它会在用户单击特定链接时向下滑动。警报栏会在指定时间段后向上滑动。如果用户多次单击此链接,我想重置计时器,向上滑动警告栏然后再次向下滑动(重置计时器)。 $(document).r
我认为这与嵌套函数有关,但它们必须是这样的。为什么它不起作用?我在做傻事吗?这是一个孤立的示例,我必须使用 $(this),所以我似乎必须嵌套函数? HTML: Hover box, it tur
我有一组复杂的 setTimeout() 调用可以触发一些 jQuery 动画。我希望能够在不知道它们的各种引用的情况下将它们全部清除。 此代码将不起作用 - 但应该说明我正在尝试做什么......
谁能看出以下代码有什么问题。它应该显示从 30 开始的倒计时,然后使用 jquery 的 ajax load() 函数刷新页面。 它在第一次或第二次倒计时时工作正常,但随后计时器开始倒计时太快,有时会
var clearId:int = setTimeout(function():void{ //some code here clearTimeout(
我的脚本: var pics = [ "mads.jpeg" ,"niggs.jpg", "rits.jpeg"]; var totalPics = pics.length; var frame
有人可以向我解释一下我下面的代码有什么问题吗?我声明一个公共(public)变量并将其设置为 setTimeout,如果不为空,则在再次设置之前清除超时。当我尝试清除超时时,我得到了未定义的信息,因此
我正在尝试在普通 JavaScript 中实现 debounce 函数。我不确定为什么clearTimeout不清除超时对象。在每个事件触发器中,回调函数setTimeout如果距上次调用不超过5秒,
我的主要问题是:clearTimeout() 是否会停止计时器并且不在计时器内执行函数?还是只是清除超时并立即执行函数? 这是我的例子 $('input').keyup(function(){
我是一名优秀的程序员,十分优秀!