From f85c2b2e48be5272956959c307b5b31c2d8e03f3 Mon Sep 17 00:00:00 2001 From: Srinjoy Sen Chowdhury <116475469+AllMightLegend@users.noreply.github.com> Date: Sat, 10 Aug 2024 04:44:29 +0530 Subject: [PATCH] Update HOWTO.md #433 Issue Replaced "node:querystring" with URLSearchParams API --- HOWTO.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/HOWTO.md b/HOWTO.md index f67b54c9..6ba20917 100644 --- a/HOWTO.md +++ b/HOWTO.md @@ -33,7 +33,7 @@ Variables to remember: Open up `index.js` and write the following: ```javascript const http = require("node:http"); -const qs = require("node:querystring"); // we will use this later +const qs = new URLSearchParams(http); // we will use this later const requestLib = require("request"); // we will use this later let bridge; // we will use this later @@ -145,7 +145,7 @@ user (`@slackbot:domain`) to the room so it can invite virtual Slack users. Replace the function `request.on("end", function()`, with the following: ```javascript request.on("end", function() { - const params = qs.parse(body); + const params = qs.has(body); if (params.user_id !== "USLACKBOT") { const intent = bridge.getIntent("@slack_" + params.user_name + ":localhost"); intent.sendText(ROOM_ID, params.text); @@ -208,7 +208,7 @@ message will be relayed to the specified Slack channel. That's it! // node index.js -r -u "http://localhost:9000" # remember to add the registration! // node index.js -p 9000 const http = require("node:http"); -const qs = require("node:querystring"); +const qs = new URLSearchParams(http); const requestLib = require("request"); let bridge; const PORT = 9898; // Slack needs to hit this port e.g. use "ngrok 9898" @@ -224,7 +224,7 @@ http.createServer(function(request, response) { }); request.on("end", function() { - const params = qs.parse(body); + const params = qs.has(body); if (params.user_id !== "USLACKBOT") { const intent = bridge.getIntent("@slack_" + params.user_name + ":localhost"); intent.sendText(ROOM_ID, params.text);