12345678910111213141516171819202122232425262728 |
- import { put, call } from 'redux-saga/effects';
- import axios from 'axios';
- import { GET_USERS } from './../../../constants/admin';
- import { getUserSuccess, getUserFailure } from './../../../actions/admin/user/getUser';
- import storageKey from '../../../utils/storageKey';
- const getItem = localStorage.getItem(storageKey);
- export default function* (payload) {
- try {
- const config = {
- headers: {
- "Content-Type": "application/json",
- "Authorization": `Bearer ${getItem}`
- }
- }
- const user = yield call(() =>
- axios.get(GET_USERS , config)
- )
- yield put(getUserSuccess(user));
- }
- catch ({ message }) {
- yield put(getUserFailure(message));
- }
- }
|