title: node.js http set request parameters
body: <p>I have a node.js application and I want to call a REST api by using <a href="https://nodejs.org/api/http.html#http_http_request_options_callback" rel="nofollow noreferrer"><code>http.request</code></a>. This is my code:</p>
  
  <pre><code>http = require("http");
  
  const options = {
          host: localhost,
          port: 8103,
          path: "/rest/getUser?userId=12345",
          method: "GET"
      };
  
  http.request(options, function(res) {
     res.setEncoding('utf8');
     res.on('data', function (chunk) {
        console.log('BODY: ' + chunk);
        resolve(JSON.parse(chunk));
     });
  }).end();
  </code></pre>
  
  <p>The above code works fine, but I don't want to include the request parameter <code>?userId=12345</code> in the path. The path should be: <code>/rest/getUser</code>. How do I set the request parameter with <code>http.request</code>?</p>