getAnswers.js 782 B

1234567891011121314151617181920212223242526272829
  1. import { put, call, all } from 'redux-saga/effects';
  2. import axios from 'axios';
  3. import { CREATE_ANSVERS } from '../../../constants/admin';
  4. import { getAnswersSuccess, getAnswersFailure} from '../../../actions/admin/changeTest/getAnswers';
  5. import storageKey from '../../../utils/storageKey';
  6. const getItem = localStorage.getItem(storageKey);
  7. export default function* ({payload:{value}}) {
  8. try {
  9. const config ={
  10. headers: {
  11. "Authorization": `Bearer ${getItem}`
  12. }
  13. }
  14. const answers = yield call(() =>
  15. axios.get(`${CREATE_ANSVERS}?question=${value}` ,config)
  16. )
  17. yield put(getAnswersSuccess(answers));
  18. }
  19. catch ({ message }) {
  20. yield put(getAnswersFailure(message));
  21. }
  22. }