title: How do I send a .json file as a HTTP POST using node.js?
body: <p>I am new to most of these concepts, so I apologize if this question is trivial. I am trying to write a script that makes an HTTP POST request that sends a .json file containing an array of jsons. I am using an npm module found here: <a href="https://github.com/request/request" rel="nofollow noreferrer">https://github.com/request/request</a>
  and a tutorial that walks you through using the module found here: 
  <a href="http://samwize.com/2013/08/31/simple-http-get-slash-post-request-in-node-dot-js/" rel="nofollow noreferrer">http://samwize.com/2013/08/31/simple-http-get-slash-post-request-in-node-dot-js/</a></p>
  
  <p>Here is the code I have so far:</p>
  
  <pre><code>//var fs = require('fs');
  var request = require('request');
  
    // Set the headers
    var headers = {
      'Content-Type': "stuff",
      'x-authorization': "stuff"
    }
  
    // Configure the request
    var options = {
        url: 'http://localhost:8080/users/add',
        method: 'POST',
        headers: headers,
        form: {
            'username': 'testuser42',
            'firstName': 'test',
            'lastName': 'user42',
            'password': 'testpassword'
        }
    }
  
    // Start the request
    request(options, function(error, response, body){
        if (!error &amp;&amp; response.statusCode == 200) {
            console.log(body)
        }
    })
  </code></pre>
  
  <p>The data.json file I am trying to send to the local server will contain an array of jsons, formatted like so:</p>
  
  <pre><code>[
    {
      "username": "testuser1",
      "firstName": "test",
      "lastName": "user1",
      "password": "password1'
    },
    {
      "username": "testuser2",
      "firstName": "test",
      "lastName": "user2",
      "password": "password2'
    }
  ]
  </code></pre>
  
  <p>So I think I need to make separate POST requests for each array element, but it is not clear to me how to do this.</p>