<commit_before>angular
  .module('Yelp', [

  ])

.factory('Yelp', ['$http', '$window', function($http, $window) {
  var Yelp = {};

  Yelp.getAccessToken = function() {
    return new Promise(function(resolve, reject) {
      var token = $window.localStorage.getItem('yelptoken');

      //if the token is in storage then use it
      if (token) {
        resolve(token);
      }

      //else generate a new token by requesting from server
      else {
        $http.get('api/auth/yelptoken')
          .then(function(response) {
            $window.localStorage.setItem('yelptoken', response.data.yelptoken);
            resolve(response.data.yelptoken);
          })
          .catch(function(error) {
            reject(error);
          });
      }
    });
  };

  Yelp.getBurgerJoints = function(lat, lon) {
    var self = this;

    self.getAccessToken()

    .then(function(token) {
      return $http.get('https://api.yelp.com/v3/business/search', {
        data: {
          term: 'burgers',
          latitude: lat,
          longitude: lon,
          sort_by: 'distance'
        },
        headers: {
          Authorization: 'Bearer ' + token
        }
      });
    })<commit_msg>Updated yelp api endpoint for testing on heroku.<commit_after>angular
  .module('Yelp', [

  ])

.factory('Yelp', ['$http', '$window', function($http, $window) {
  var Yelp = {};

  Yelp.getAccessToken = function() {
    return new Promise(function(resolve, reject) {
      var token = $window.localStorage.getItem('yelptoken');

      //if the token is in storage then use it
      if (token) {
        resolve(token);
      }

      //else generate a new token by requesting from server
      else {
        $http.get('api/auth/yelptoken')
          .then(function(response) {
            $window.localStorage.setItem('yelptoken', response.data.yelptoken);
            resolve(response.data.yelptoken);
          })
          .catch(function(error) {
            reject(error);
          });
      }
    });
  };

  Yelp.getBurgerJoints = function(lat, lon) {
    var self = this;

    self.getAccessToken()

    .then(function(token) {
      return $http.get('https://api.yelp.com/v3/businesses/search', {
        data: {
          term: 'burgers',
          latitude: lat,
          longitude: lon,
          sort_by: 'distance'
        },
        headers: {
          Authorization: 'Bearer ' + token
        }
      });
    })
{'fraction_non_alphanumeric': 0.14215080346106304, 'fraction_numerical': 0.0008240626287597857, 'mean_word_length': 1.9718482252141982, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, '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': '5190776', 'n_tokens_mistral': 776, 'n_tokens_neox': 732, 'n_words': 147}