import { call, put } from 'redux-saga/effects'; import { projectUserListFailure, projectUserListSuccess, projectListFailure, projectListSuccess } from '../actions/project'; export function* projectUserListSaga() { let result try { result = yield call(projectUserList); } catch(err) { yield put(projectUserListFailure(err)); return } if ('error' in result) { yield put(projectUserListFailure(result.error)); return } yield put(projectUserListSuccess(result.data)); } const projectUserList = () => { return fetch('http://localhost:8001/api/v1/me', { method: 'GET', mode: 'cors', credentials: 'include' }).then(res => res.json()) } export function* projectListSaga() { let result try { result = yield call(projectList); } catch(err) { yield put(projectListFailure(err)); return } if ('error' in result) { yield put(projectListFailure(result.error)); return } yield put(projectListSuccess(result.data)); } const projectList = () => { return fetch('http://localhost:8001/api/v1/projects', { method: 'GET', mode: 'cors', credentials: 'include' }).then(res => res.json()) }