From a165043d13ef7b6b4f827d2ff5a69635eca29c4d Mon Sep 17 00:00:00 2001 From: menshibin Date: Tue, 11 Feb 2025 10:44:49 +0800 Subject: [PATCH] docs(node):fix node.js wsconfig case --- docs/zh/14-reference/05-connector/35-node.mdx | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/docs/zh/14-reference/05-connector/35-node.mdx b/docs/zh/14-reference/05-connector/35-node.mdx index cb5d69d137..d15a7a5a63 100644 --- a/docs/zh/14-reference/05-connector/35-node.mdx +++ b/docs/zh/14-reference/05-connector/35-node.mdx @@ -130,16 +130,20 @@ Node.js 连接器(`@tdengine/websocket`), 其通过 taosAdapter 提供的 We 除了通过指定的 URL 获取连接,还可以使用 WSConfig 指定建立连接时的参数。 ```js -try { - let url = 'ws://127.0.0.1:6041' - let conf = WsSql.NewConfig(url) - conf.setUser('root') - conf.setPwd('taosdata') - conf.setDb('db') - conf.setTimeOut(500) - let wsSql = await WsSql.open(conf); -} catch (e) { - console.error(e); +const taos = require("@tdengine/websocket"); + +async function createConnect() { + try { + let url = 'ws://127.0.0.1:6041' + let conf = WsSql.NewConfig(url) + conf.setUser('root') + conf.setPwd('taosdata') + conf.setDb('db') + conf.setTimeOut(500) + let wsSql = await taos.sqlConnect(conf) + } catch (e) { + console.error(e); + } } ```