import { put, call, all } from 'redux-saga/effects'; import axios from 'axios'; import { CREATE_TOPICS } from '../../../constants/admin'; import { getTopicSuccess, getTopicFailure} from '../../../actions/admin/changeTest/getTopic'; import storageKey from '../../../utils/storageKey'; const getItem = localStorage.getItem(storageKey); export default function* ({payload:{_id}}) { try { const config ={ headers: { "Authorization": `Bearer ${getItem}` } } const topic = yield call(() => axios.get(`${CREATE_TOPICS}?category=${_id}` ,config) ) yield put(getTopicSuccess(topic)); } catch ({ message }) { yield put(getTopicFailure(message)); } }