<commit_before>var Path = require('path');
var request = require('request');
var catList = ["2636","3920","3920_582507_583874", "4044_133012_1045881", "3944",
  "4104", "4171_4191", "5438_426265_1032639","4096","4125_4161","1085632_1229464",
  "2637_667479","4171","4171_1015079","4171_1111647"]
var mathRan = function (){return (Math.floor(Math.random() * (catList.length - 0)) + 0)}
var mathRan2 = function (){return (Math.floor(Math.random() * (50 - 0)) + 0)}
// var url = "http://api.walmartlabs.com/v1/paginated/items?format=json&category="+ catList[mathRan()]+"&apiKey=<KEY>"


module.exports = {

//show api
  show: function(req,res){ //for home page

    var catArray = []
    for (var i = 0; i < 4; i++) {
      catArray[i] = "http://api.walmartlabs.com/v1/paginated/items?format=json&category="+ catList[mathRan()]+"&apiKey=<KEY>"
    }

    var data = []

    request({url: catArray[0], json: true}, function(error, response, body){
      var randoItem = body.items[mathRan2()]
      data.push(randoItem)
      
      request({url: catArray[1], json: true}, function(error, response, body){
        var randoItem = body.items[mathRan2()]
        data.push(randoItem)

        request({url: catArray[2], json: true}, function(error, response, body){
          var randoItem = body.items[mathRan2()]
          data.push(randoItem)

          request({url: catArray[3], json: true}, function(error, response, body){
            var randoItem = body.items[mathRan2()]
            data.push(randoItem)

            res.json(data)<commit_msg>added better math random that gives us the full array of items returned from api call<commit_after>var Path = require('path');
var request = require('request');
var catList = ["2636","3920","3920_582507_583874", "4044_133012_1045881", "3944",
  "4104", "4171_4191", "5438_426265_1032639","4096","4125_4161","1085632_1229464",
  "2637_667479","4171","4171_1015079","4171_1111647"]
var mathRan = function (){return (Math.floor(Math.random() * (catList.length - 0)) + 0)}

// var url = "http://api.walmartlabs.com/v1/paginated/items?format=json&category="+ catList[mathRan()]+"&apiKey=<KEY>"


module.exports = {

//show api
  show: function(req,res){ //for home page

    var catArray = []
    for (var i = 0; i < 4; i++) {
      catArray[i] = "http://api.walmartlabs.com/v1/paginated/items?format=json&category="+ catList[mathRan()]+"&apiKey=<KEY>"
    }

    var data = []

    request({url: catArray[0], json: true}, function(error, response, body){
      var mathRan2 = function (){return (Math.floor(Math.random() * (body.items.length - 0)) + 0)}
      var randoItem = body.items[mathRan2()]
      data.push(randoItem)

      request({url: catArray[1], json: true}, function(error, response, body){
        var mathRan2 = function (){return (Math.floor(Math.random() * (body.items.length - 0)) + 0)}
        var randoItem = body.items[mathRan2()]
        data.push(randoItem)

        request({url: catArray[2], json: true}, function(error, response, body){
          var mathRan2 = function (){return (Math.floor(Math.random() * (body.items.length - 0)) + 0)}
          var randoItem = body.items[mathRan2()]
          data.push(randoItem)

          request({url: catArray[3], json: true}, function(error, response, body){
            var mathRan2 = function (){return (Math.floor(Math.random() * (body.items.length - 0)) + 0)}
            var randoItem = body.items[mathRan2()]
            data.push(randoItem)

            res.json(data)
{'fraction_non_alphanumeric': 0.17817244342595245, 'fraction_numerical': 0.09080492695502722, 'mean_word_length': 3.693548387096774, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3260545', 'n_tokens_mistral': 1398, 'n_tokens_neox': 1228, 'n_words': 242}