title: Nodejs filter data and send it as response
body: <p>I have an array of data I have a function that filter the array get the data I want and send it as a response. </p>
  
  <p>The problem is the function sends the 1st array only, 
  for example here is the data:</p>
  
  <pre><code>[
      {
          "name": "2 Hours 30 Min (2.5 Hours)",
          "price": 20,
          "rewardPoints": 50,
          "priceInPoints": 1000,
          "minutes": 150,
          "id": 8
      },
      {
          "name": "5 Hours",
          "price": 40,
          "rewardPoints": 100,
          "priceInPoints": 1800,
          "minutes": 300,
          "id": 7
      }
  ]
  </code></pre>
  
  <p>Code:</p>
  
  <pre class="lang-js prettyprint-override"><code>getRequest(timeProducts)
    .then(response =&gt; {
      const result = response.data.result;
      result.forEach(data =&gt; {
        if (data.pointsPrice != null) {
          res.json({
            name: data.name,
            price: data.price,
            rewardPoints: data.points,
            priceInPoints: data.pointsPrice,
            minutes: data.minutes
          });
        }
      });
    })
    .catch(errorMessage =&gt; {
      res.json(errorMessage);
    });
  </code></pre>
  
  <p>What I get is :</p>
  
  <pre><code>{
      "name": "2 Hours 30 Min (2.5 Hours)",
      "price": 20,
      "rewardPoints": 50,
      "priceInPoints": 1000,
      "minutes": 150,
      "id": 8
  }
  </code></pre>
  
  <p>But I want all.</p>
  
  <p>What am I doing wrong here?</p>
  
  <p>And what's the best approach to even make this function better?</p>