Answer: How to pass variables in URL in NodeJS

anujpancholi

Anuj Pancholi

Posted on February 25, 2020

Answer: How to pass variables in URL in NodeJS

One way to do it is using template literals, which has been discussed in other answers (I encourage you to check out the link shared by Jason).

const phone = "1234567890";
const message = "my-message-content";

const url = `http://www.techsolver.in/http-api.php?username=abc&password=pwd&senderid=MYID&route=1&number=${phone}&message=${message}`

console.log(url);

However, if…

Why node has a querystring module, to perform tasks that, at first glance, seem trivial.

💖 💪 🙅 🚩
anujpancholi
Anuj Pancholi

Posted on February 25, 2020

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related