import { put, call } from 'redux-saga/effects'; import axios from 'axios'; import { USER_URL } from './../../constants/user'; import { changeEmailSuccess, changeEmailFailure } from './../../actions/user/changeEmail' export default function* ({payload:{_id,email,token}}) { console.log('User inside the worker-saga', _id,email,token); try { const config = { headers: { "Content-Type": "application/json", "Authorization": `Bearer ${token}` } } const user = yield call(() => axios.put(`${USER_URL}${_id}`,{email:email}, config) .then(({ data }) => data) ) yield put(changeEmailSuccess(user)); } catch ({ message }) { yield put(changeEmailFailure(message)); } }