import { ApiResponse } from "apisauce" ; import { path } from "ramda" ; import { SagaIterator } from "redux-saga" ; import { call , put } from "redux-saga/effects" ; import { GithubAction , GithubActions } from "../../Reducers/GithubReducers" ; import { GithubApi , GithubResponse , GithubUser } from "../../Services/GithubApi" ; export function * getUserAvatar ( api , action ) { const { payload } = action ; const response = yield call ( api . getUser , payload . username ) ; if ( response . ok ) { const firstUser = path < GithubUser [ ] > ( [ "data" , "items" ] , response ) [ 0 ] ; const avatar = firstUser . avatar_url ; yield put ( GithubActions . userSuccess ( { avatar } ) ) ; } else { yield put ( GithubActions . userFailure ( ) ) ; } }