Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import {USER_LIST_URL} from './../app/apiRoutes';
- import cookie from 'react-cookie';
- import axios from 'axios';
- export const SET_USERNAME = 'SET_USERNAME';
- export const SET_PASSWORD = 'SET_PASSWORD';
- export const LOAD_USERS_SUCCESS = 'LOAD_USERS_SUCCESS';
- export const LOAD_USERS_ERROR = 'LOAD_USERS_SUCCESS';
- export function setUsername(username) {
- return { type: SET_USERNAME, username };
- }
- export function setPassword(password) {
- return { type: SET_PASSWORD, password };
- }
- export function receiveError() {
- return {type: LOAD_USERS_ERROR};
- }
- export function receiveSuccess(users) {
- console.log('Run method in action users;')
- return {type: LOAD_USERS_SUCCESS, users};
- }
- export function loadUsers() {
- return dispatch => {
- return axios({
- url: USER_LIST_URL,
- timeout: 20000,
- method: 'get',
- responseType: 'json',
- headers: {
- Authorization: cookie.load('Authorization')
- }
- })
- .then(function(response) {
- dispatch(receiveSuccess(response.data));
- })
- .catch(function(){
- });
- };
- }
Add Comment
Please, Sign In to add comment