Created
May 12, 2019 19:11
-
-
Save jitinics/0568cacae7d12c198f06bc42d21550cb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { takeEvery, put, call, fork } from 'redux-saga/effects' | |
import UserProvider from '../../resources/UserProvider' | |
const userProvider = new UserProvider() | |
function *loginRequest() { | |
yield takeEvery('LOGIN', login) | |
} | |
function* login(action) { | |
try { | |
yield put({type: "INCREASE_LOADING"}); | |
const result = yield call(userProvider.signIn, action.payload.email, action.payload.password) | |
yield put({type: "LOGIN_SUCCESS", payload: result.data}); | |
} catch (e) { | |
console.log(e) | |
} finally { | |
yield put({type: "DECREASE_LOADING"}); | |
} | |
} | |
export default loginRequest |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment