How do I URl encode something in Node js

0 votes

I want to URL encode this:

SELECT name FROM user WHERE uid = me() 

Do I have to download a module for this? I already have the request module.

Jul 14, 2020 in Node-js by kartik
• 37,520 points
2,380 views

1 answer to this question.

0 votes

Hello @kartik,

The built-in module querystring is what you're looking for:

var querystring = require("querystring");
var result = querystring.stringify({query: "SELECT name FROM user WHERE uid = me()"});
console.log(result);
#prints 'query=SELECT%20name%20FROM%20user%20WHERE%20uid%20%3D%20me()'

Hope it helps!!
Thank you!!

answered Jul 14, 2020 by Niroj
• 82,840 points

Related Questions In Node-js

0 votes
1 answer

How do I manage MongoDB connections in a Node.js web application?

When the Node.js application starts, create a ...READ MORE

answered Jun 10, 2022 in Node-js by Neha
• 9,020 points
1,953 views
0 votes
1 answer

How do I get the path to the current script with Node.js?

Hello @kartik, you can do this: fs.readFile(path.resolve(__dirname, 'settings.json'), 'UTF-8', ...READ MORE

answered Jul 8, 2020 in Node-js by Niroj
• 82,840 points
2,815 views
0 votes
1 answer

How do I update Node.js?

Hello @kartik, First update npm, npm install -g npm stable Then ...READ MORE

answered Jul 8, 2020 in Node-js by Niroj
• 82,840 points
721 views
0 votes
1 answer

How do I determine the current operating system with Node.js

Hello @kartik, With Node.js v6 (and above) there ...READ MORE

answered Jul 14, 2020 in Node-js by Niroj
• 82,840 points
3,813 views
0 votes
1 answer

jQuery AJAX fires error callback on window unload - how do I filter out unload and only catch real errors?

Hello, In the error callback or $.ajax you have three ...READ MORE

answered Apr 27, 2020 in Java-Script by Niroj
• 82,840 points
4,174 views
0 votes
1 answer

How do I pass command line arguments to a Node.js program?

Hello @kartik, If your script is called myScript.js ...READ MORE

answered May 5, 2020 in Java-Script by Niroj
• 82,840 points
3,232 views
0 votes
1 answer

Error:Issue when trying to use IN() in wordpress database

Hello @kartik, Try this code : // Create an ...READ MORE

answered May 8, 2020 in PHP by Niroj
• 82,840 points
1,105 views
+2 votes
1 answer

How do I debug Node.js applications?

Hello @kartik, Use node-inspector  from any browser supporting WebSocket. Breakpoints, ...READ MORE

answered Jul 8, 2020 in Node-js by Niroj
• 82,840 points
1,023 views
0 votes
1 answer

How do I get the time of day in javascript/Node.js?

Hello @kartik, This function will return you the ...READ MORE

answered Sep 7, 2020 in Node-js by Niroj
• 82,840 points
1,166 views
0 votes
1 answer

How do I parse a data URL in Node?

Hello @kartik, Put the data into a Buffer ...READ MORE

answered Nov 30, 2020 in Node-js by Niroj
• 82,840 points
1,782 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP