signIn.js 703 B

123456789101112131415161718192021222324252627
  1. import { put, call } from 'redux-saga/effects';
  2. import axios from 'axios';
  3. import { SIGN_IN_URL } from './../../constants/auth';
  4. import { signInSuccess, signInFailure } from './../../actions/auth/signIn'
  5. export default function* ({payload}) {
  6. console.log('User inside the worker-saga', payload);
  7. try {
  8. const config = {
  9. headers: {
  10. "Content-Type": "application/json"
  11. }
  12. }
  13. const user = yield call(() =>
  14. axios.post(SIGN_IN_URL, payload, config)
  15. .then(({ data }) => data)
  16. )
  17. yield put(signInSuccess(user));
  18. }
  19. catch ({ message }) {
  20. yield put(signInFailure(message));
  21. }
  22. }