Can anyone help me determine why firebase isn't returning the value from a cloud function?
It seems like reading from on database change is simple, but when doing a http on request, firebase functions just hangs and finally times out.

```
exports.getTotalPrice = functions.https.onRequest((req, res) => {
  var data = "";
   req.on('data', function(chunk){ data += chunk})
   req.on('end', function(){
       req.rawBody = data;
       req.jsonBody = JSON.parse(data);
       res.end(next(req.jsonBody));
   })
});
function next(json) {
  var total = 0;
  for(var i = 0; i < json.products.length; i++) {
    //Get product by UPC
    console.log(order.products[i].upc);
    codeRef.orderByKey()
      .equalTo(order.products[i].upc)
        .once('value', function(snap) {
          console.log(snap.val()); // returns `null`
          return (snap.val()[0].msrp);
    })
    //Multiply the price of the product by the quantity
    console.log(order.products[i].quantity);

    //add it to the total price
  }
}

```