12345678910111213141516171819202122232425262728 |
- import { put, call } from 'redux-saga/effects';
- import axios from 'axios';
- import { CREATE_QUESTIONS } from '../../../constants/admin';
- import { deleteQuestionSuccess, deleteQuestionFailure } from '../../../actions/admin/changeTest/deleteQuestion';
- import storageKey from '../../../utils/storageKey';
- const getItem = localStorage.getItem(storageKey);
- export default function* ({ payload: { questionId } }) {
- try {
- const config = {
- headers: {
- "Authorization": `Bearer ${getItem}`
- }
- }
- const question = yield call(() =>
- axios.delete(`${CREATE_QUESTIONS}${'/'}${questionId}`, config)
- )
- yield put(deleteQuestionSuccess(question));
- }
- catch ({ message }) {
- yield put(deleteQuestionFailure(message));
- }
- }
|