{"size": 774, "ext": "js", "max_stars_repo_path": "src/js/asgard/actions/AccountActions.js", "max_stars_repo_name": "dehmirandac2/asgard-ui", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/js/asgard/actions/AccountActions.js", "max_issues_repo_name": "dehmirandac2/asgard-ui", "max_issues_repo_issues_event_min_datetime": "2020-01-10T22:42:26.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-12T09:52:08.000Z", "max_forks_repo_path": "src/js/asgard/actions/AccountActions.js", "max_forks_repo_name": "dehmirandac2/asgard-ui", "max_forks_repo_forks_event_min_datetime": "2020-03-25T14:09:24.000Z", "max_forks_repo_forks_event_max_datetime": "2020-04-27T17:34:34.000Z"}
{"max_stars_count": null, "max_issues_count": 13, "max_forks_count": 2, "avg_line_length": 29.7692307692, "max_line_length": 61, "alphanum_fraction": 0.6589147287}
import ajaxWrapper from "../../helpers/ajaxWrapper";
import AppDispatcher from "../../AppDispatcher";
import AccountsEvents from "../events/AccountsEvents";
import config from "../../config/config";
import AccountsStore from "../stores/AccountsStore";

var AccountActions = {
  requestToken: function (account) {
    this.request({
      url: `${config.apiURL}accounts/${account}/auth`
    })
      .success(function (account) {
        localStorage.setItem("auth_token", account.body.jwt);
        AccountsStore.emit(AccountsEvents.CHANGE);
      })
      .error(function (error) {
        AppDispatcher.dispatch({
          actionType: AccountsEvents.REQUEST_ERROR,
          data: error
        });
      });
  },
  request: ajaxWrapper
};

export default AccountActions;