TypeError: You Provided an invalid object where a stream was expected. You can provide an Observable, Promise, Array, or Iterable.
//action.js
import { map,mergeMap } from 'rxjs/operators';
import {ofType } from 'redux-observable'
import { ajax } from 'rxjs/ajax';
const fetchUser = username => ({ type: 'FETCH_USER', payload: username });
export const fetchUserFulfilled = payload => ({ type: 'FETCH_USER_FULFILLED', payload });
export const fetchUserEpic = action$ => action$.pipe(
ofType('FETCH_USER'),
mergeMap(action =>
ajax.getJSON(`https://api.github.com/users/${action.payload}`).pipe(
map(response => fetchUserFulfilled(response))
)
)
);
export default fetchUser
const epicMiddleware = createEpicMiddleware();
const store = createStore(rootReducer,applyMiddleware(epicMiddleware))
epicMiddleware.run(rootEpic);
I found the answer. It is not the problem of redux-observable.
I imported the epic instead of action creators and use it in the react component.
Thank you.