Created
April 20, 2019 00:52
-
-
Save rafael-metractive/1148e742f311e8270d86f23c3986355e to your computer and use it in GitHub Desktop.
This file contains 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 { call, put, takeEvery, select } from 'redux-saga/effects' | |
// Services | |
import { callApi, callServiceApi } from 'services/api' | |
function* login(action) { | |
try { | |
// Set loading state | |
yield put({ | |
type: 'USER_SET_LOADING', | |
payload: true | |
}) | |
const response = yield call(callApi, { | |
title: 'USER LOGIN', | |
endpoint: `/login`, | |
method: 'POST', | |
data: action.payload | |
}) | |
console.log('[USER LOGIN RESPONSE]', response) | |
if (response.status == 200) { | |
} | |
} catch ({ message, response }) { | |
console.warn('[USER LOGIN ERROR]', { message, response }) | |
yield put({ | |
type: 'USER_SET_LOADING', | |
payload: false | |
}) | |
} | |
export default function* rootUser() { | |
yield takeEvery('USER_LOGIN_TRIGGER', login) | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment