deleteTopic.js 802 B

12345678910111213141516171819202122232425262728
  1. import { put, call } from 'redux-saga/effects';
  2. import axios from 'axios';
  3. import { CREATE_TOPICS } from '../../../constants/admin';
  4. import { deleteTopicSuccess, deleteTopicFailure } from '../../../actions/admin/changeTest/deleteTopic';
  5. import storageKey from '../../../utils/storageKey';
  6. const getItem = localStorage.getItem(storageKey);
  7. export default function* ({payload:{topicId}}) {
  8. try {
  9. const config = {
  10. headers: {
  11. "Authorization": `Bearer ${getItem}`
  12. }
  13. }
  14. const category = yield call(() =>
  15. axios.delete(`${CREATE_TOPICS}${'/'}${topicId}`, config)
  16. )
  17. yield put(deleteTopicSuccess(category));
  18. }
  19. catch ({ message }) {
  20. yield put(deleteTopicFailure(message));
  21. }
  22. }