{"size": 1057, "ext": "js", "max_stars_repo_path": "example/frontend/src/actions/devices.js", "max_stars_repo_name": "KENTIVO/rest-multi-factor", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "example/frontend/src/actions/devices.js", "max_issues_repo_name": "KENTIVO/rest-multi-factor", "max_issues_repo_issues_event_min_datetime": "2019-11-16T14:49:48.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-26T17:04:19.000Z", "max_forks_repo_path": "example/frontend/src/actions/devices.js", "max_forks_repo_name": "KENTIVO/rest-multi-factor", "max_forks_repo_forks_event_min_datetime": "2020-02-05T15:01:53.000Z", "max_forks_repo_forks_event_max_datetime": "2020-02-05T15:01:53.000Z"}
{"max_stars_count": null, "max_issues_count": 7, "max_forks_count": 1, "avg_line_length": 25.1666666667, "max_line_length": 71, "alphanum_fraction": 0.6073793756}
import axios from "axios";
import config from  "../config";

import {

    GENERAL_FAILURE,

    SET_REGISTER_DEVICES,
    SET_VERIFIER_DEVICES,

} from "../reducers/types";


export const get_all_devices = () => dispatch => {

    const session = localStorage.getItem("token");
    const headers = {authorization: `Token ${session}`};

    axios.get(config.locate("/multi-factor/register/"), {headers})
        .then(response => {
            dispatch({type: SET_REGISTER_DEVICES, data: response.data})
        })
        .catch(response => {
            dispatch({type: GENERAL_FAILURE, data: response})
        })
};


export const get_usr_devices = () => dispatch => {

    const session = localStorage.getItem("token");
    const headers = {authorization: `Token ${session}`};

    axios.get(config.locate("/multi-factor/"), {headers})
        .then(response => {
            dispatch({type: SET_VERIFIER_DEVICES, data: response.data})
        })
        .catch(response => {
            dispatch({type: GENERAL_FAILURE, data: response})
        })
};
