Skip to content

Instantly share code, notes, and snippets.

@rafael-metractive
Created April 20, 2019 00:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rafael-metractive/1148e742f311e8270d86f23c3986355e to your computer and use it in GitHub Desktop.
Save rafael-metractive/1148e742f311e8270d86f23c3986355e to your computer and use it in GitHub Desktop.
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