title: Parsing arrays in req.body in node js express
body: <p>I am getting an array in request body like :</p>
  
  <pre><code>[
  
  {
     "month" : "JUL",
     "year" :"2018"
  },
  {
     "month" : "JAN",
     "year" :"2018"
  },
  {
     "month" : "MAR",
     "year" :"2018"
  }
      ]
  </code></pre>
  
  <p>This input has two parameters (month:enum and year:string).</p>
  
  <p>I need to loop through this array and call the chaincode and finally send the response . I have done the following :</p>
  
  <pre><code>     for(var i=0; i&lt;req.body.length; i++) {
                      var month = req.body[i].month;
                      var year = req.body[i].year;
                      var monthYear = month + year;
      key = monthYear + "_new";
          console.log("Key is ", key);
              var request = {
              //targets: let default to the peer assigned to the client
              chaincodeId: 'abc',
              fcn: 'getTransactionsByKey',
              args: [key]
  
  //Calling chaincode smartcontract
  return channel.queryByChaincode(request);
  }
  </code></pre>
  
  <p>but the response is coming correct if I pass only one input parameter . If I pass two values in input , the 2nd value result overrides the first one . Any help on how can I get response for all the list of inputs with the overlapping part.</p>
  
  <p>Also , I need to sort the input values before calling the chaincode , like if I get Feb Mar Jan in the input , I should sort it as Jan Feb Mar and then run the for loop.</p>
  
  <p>Any help on this is appreciated.</p>
  
  <p>Thanks in advance.
  Thanks.</p>