In redux-observable
is it possible to use isomporphic-fetch instead of Rx.DOM.ajax?
Did small adjustment to @jayphelps in order to get that code work for me. Hope this helps to save someone's time.
import { FETCH_USER } from './actions'
import { ofType } from 'redux-observable'
import { map, mergeMap } from 'rxjs/operators'
import { from } from 'rxjs'
const fetchUserEpic = action$ => {
return action$.pipe(
ofType(FETCH_USER),
mergeMap((action = { user: 'redux-observable' }) => {
const getRequest = (user) => {
const request = fetch(`https://api.github.com/users/${user}`)
.then(response => response.json())
return from(request)
}
return getRequest(action.user).pipe(
map(payload => ({ type: FETCH_USER_FULFILLED, payload }))
)
})
)
}