{"size": 624, "ext": "js", "max_stars_repo_path": "assets/app/sagas/home/getVisitedRooms.js", "max_stars_repo_name": "samuelbriole/Jukee", "max_stars_repo_stars_event_min_datetime": "2018-05-17T17:43:06.000Z", "max_stars_repo_stars_event_max_datetime": "2018-06-09T02:12:25.000Z", "max_issues_repo_path": "assets/app/sagas/home/getVisitedRooms.js", "max_issues_repo_name": "samuelbriole/Jukee", "max_issues_repo_issues_event_min_datetime": "2018-06-04T15:51:36.000Z", "max_issues_repo_issues_event_max_datetime": "2018-06-20T11:31:23.000Z", "max_forks_repo_path": "assets/app/sagas/home/getVisitedRooms.js", "max_forks_repo_name": "samuelbriole/jukee", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 3, "max_issues_count": 2, "max_forks_count": null, "avg_line_length": 26.0, "max_line_length": 68, "alphanum_fraction": 0.7243589744}
import { takeEvery } from 'redux-saga';
import { call, put } from 'redux-saga/effects';

import api from 'utils/api';
import { getVisitedRoomsRoutine } from 'actions/home';

function* getRooms() {
  const response = yield call(api.get, '/visited-rooms');
  return response.data.data;
}

function* getVisitedRooms() {
  try {
    const results = yield call(getRooms);
    yield put(getVisitedRoomsRoutine.success(results));
  } catch (error) {
    yield put(getVisitedRoomsRoutine.failure(error));
  }
}

export default function* getVisitedRoomsSaga() {
  yield* takeEvery(getVisitedRoomsRoutine.REQUEST, getVisitedRooms);
}
