<commit_before>const request = require('request-promise');
const fredTools = require('../fred/parseTools');
require('dotenv').config();


const weather = {

  getResponse: (loc, placeStr, originalStr) => {

    console.log('ran weather');

    if(!placeStr) {
      var query = 'http://api.openweathermap.org/data/2.5/weather?lat=' + loc.lat + '&lon=' + loc.lon;
    } else {
      query = 'http://api.openweathermap.org/data/2.5/weather?q=' + placeStr;
    }
    var options = {
      uri: query,
      method: 'GET',
      headers: {
        'User-Agent': 'Request-Promise',
        'Content-Type': 'application/x-www-form-urlencoded',
        'x-api-key': `${process.env.weather_api_key}`
      }
    };
   
   return request(options)
    .then((data) => {

      let weatherObj = JSON.parse(data);

      let response = fredTools.constructWeathertext(originalStr, weatherObj);

      let apiResponse = {
        type: 'widget',
        api: 'weather',
        text: response,
        data: weatherObj
      };
      return apiResponse;
    })<commit_msg>ES6 Refactor weather.js<commit_after>const request = require('request-promise');
const fredTools = require('../fred/parseTools');
require('dotenv').config();


const weather = {

  getResponse: (loc, placeStr, originalStr) => {

    console.log('ran weather');

    if(!placeStr) {
      var query = 'http://api.openweathermap.org/data/2.5/weather?lat=' + loc.lat + '&lon=' + loc.lon;
    } else {
      query = 'http://api.openweathermap.org/data/2.5/weather?q=' + placeStr;
    }
    let options = {
      uri: query,
      method: 'GET',
      headers: {
        'User-Agent': 'Request-Promise',
        'Content-Type': 'application/x-www-form-urlencoded',
        'x-api-key': `${process.env.weather_api_key}`
      }
    };
   
   return request(options)
    .then((data) => {

      let weatherObj = JSON.parse(data);

      let response = fredTools.constructWeathertext(originalStr, weatherObj);

      let apiResponse = {
        type: 'widget',
        api: 'weather',
        text: response,
        data: weatherObj
      };
      return apiResponse;
    })
{'fraction_non_alphanumeric': 0.1632173095014111, 'fraction_numerical': 0.0042333019755409216, 'mean_word_length': 2.5332225913621262, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '4702188', 'n_tokens_mistral': 701, 'n_tokens_neox': 674, 'n_words': 124}