title: form-data post request using https in node.js
body: <p>How can I send form-data post request using http package?</p>
  <p>I have working code with &quot;request&quot; package:</p>
  <pre><code>let result = await request({
      url: getTokenURL,
      method: &quot;POST&quot;,
      form: `login=${login}&amp;password=${password}`
  });
  </code></pre>
  <p>but I want do the same with native http</p>
  <p>trying this:</p>
  <pre><code>let getToken = function(url, login, password){
      return new Promise((resolve, reject) =&gt; {
          let getTokenURL = `${url}`;
          
          console.log(`requesting ${getTokenURL}`);
          
          let httpRequest = http.request({
              uri: getTokenURL,
              port: 80,
              method: 'POST',
              form: `login=${login}&amp;password=${password}`
          }, (response) =&gt; {
              let body = '';
  
              response.on('data', (chunk) =&gt; {
                  body += chunk;
              });
            
              response.on('end', () =&gt; {
                  console.log(body);
                  return resolve(body);
              });
          });
      });
  }  
  </code></pre>
  <p>but it's raising an error<a href="https://i.stack.imgur.com/7ru4A.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7ru4A.png" alt="enter image description here" /></a></p>