{"size": 801, "ext": "js", "max_stars_repo_path": "src/actions/weather.js", "max_stars_repo_name": "husa/e-clock", "max_stars_repo_stars_event_min_datetime": "2015-10-06T06:29:56.000Z", "max_stars_repo_stars_event_max_datetime": "2020-07-30T22:10:17.000Z", "max_issues_repo_path": "src/actions/weather.js", "max_issues_repo_name": "husa/e-clock", "max_issues_repo_issues_event_min_datetime": "2019-01-07T00:19:04.000Z", "max_issues_repo_issues_event_max_datetime": "2021-09-05T01:46:52.000Z", "max_forks_repo_path": "src/actions/weather.js", "max_forks_repo_name": "husa/e-clock", "max_forks_repo_forks_event_min_datetime": "2015-10-15T20:54:55.000Z", "max_forks_repo_forks_event_max_datetime": "2015-10-15T20:54:55.000Z"}
{"max_stars_count": 8, "max_issues_count": 2, "max_forks_count": 1, "avg_line_length": 24.2727272727, "max_line_length": 59, "alphanum_fraction": 0.7415730337}
import weather from '../services/weather';

export const WEATHER_LOAD_REQUEST = 'WEATHER_LOAD_REQUEST';
export const WEATHER_LOAD_SUCCESS = 'WEATHER_LOAD_SUCCESS';
export const WEATHER_LOAD_FAILURE = 'WEATHER_LOAD_FAILURE';


export const loadWeatherRequest = location => ({
  type: WEATHER_LOAD_REQUEST,
  location
});

export const loadWeatherSuccess = (data, location) => ({
  type: WEATHER_LOAD_SUCCESS,
  data,
  location
});

export const loadWeatherFailure = (error, location) => ({
  type: WEATHER_LOAD_FAILURE,
  error,
  location
});

export const loadWeather = location => dispatch => {
  dispatch(loadWeatherRequest(location));

  return weather.fetch(location).then(
    data => dispatch(loadWeatherSuccess(data, location)),
    err => dispatch(loadWeatherFailure(err, location))
  );
};
