How to URl encode strings in Node.js?

Sometimes, we want to URl encode strings in Node.js.

In this article, we’ll look at how to URl encode strings in Node.js.

How to URl encode strings in Node.js?

To URl encode strings in Node.js, we can call encodeURIComponent.

For instance, we write

encodeURIComponent('select * from table where uid = me()')

to call encodeURIComponent with return a string that is URI encoded.

Conclusion

To URl encode strings in Node.js, we can call encodeURIComponent.