import { call, put, takeEvery } from 'redux-saga/effects'

import endpoints from '../endpoints'
import actionTypes from '../actions/action-types'
import * as actionCreators from '../actions/login'

function* attemptLogin(){
  try {
    const data = yield call(fetch, endpoints.login, {
      method: 'POST', body: { username: 'nayben@gmail.com', password: 'derp' }
    })
    console.log(data)
    yield put(actionCreators.loginRedirect())
  } catch(e){
    yield put(actionCreators.loginError())
  }
}

function* loginSaga(){
  yield takeEvery(actionTypes.LOGIN_ATTEMPT, attemptLogin)
}

export default loginSaga

@@ -214,16 +214,34 @@
 ptLogin(
+username, password
 )%7B%0A  try
@@ -341,26 +341,16 @@
 me: 
-'nayben@gmail.com'
+username
 , pa
@@ -361,15 +361,16 @@
 rd: 
-'derp' 
+password
 %7D%0A  
@@ -382,25 +382,31 @@
     
-console.log(data)
+if (data)%7B%0A      %0A    %7D
 %0A   

implement login with hard coded user + add endpoints