title: rxjs process ajax request
body: <p>I'm trying to apply the ajax method posted here: <a href="https://github.com/redux-observable/redux-observable/blob/master/docs/basics/Epics.md" rel="nofollow noreferrer">https://github.com/redux-observable/redux-observable/blob/master/docs/basics/Epics.md</a></p>
  
  <pre><code>import { ajax } from 'rxjs/ajax';
  
  // action creators
  const fetchUser = username =&gt; ({ type: FETCH_USER, payload: username });
  const fetchUserFulfilled = payload =&gt; ({ type: FETCH_USER_FULFILLED, payload });
  
  // epic
  const fetchUserEpic = action$ =&gt; action$.pipe(
    ofType(FETCH_USER),
    mergeMap(action =&gt;
      ajax.getJSON(`https://api.github.com/users/${action.payload}`).pipe(
        map(response =&gt; fetchUserFulfilled(response))
      )
    )
  );
  
  // later...
  dispatch(fetchUser('torvalds'));
  </code></pre>
  
  <p>When trying this method, I get the message: </p>
  
  <blockquote>
    <p>TypeError: Object(...)(...).pipe is not a function</p>
  </blockquote>
  
  <p>So pipe doesn't appear to exist. (It concerns the second pipe after the ajax call).<br>
  How do I fix this? </p>
  
  <p>I installed the following dependencies: </p>
  
  <pre><code>"rxjs": "^6.5.2",
  "rxjs-compat": "^6.5.2",
  </code></pre>
  
  <p>Edit: </p>
  
  <p>I changed my code to <code>ajax.get</code> and the calling code: </p>
  
  <pre><code>export const fetchTrendingEpic = action$ =&gt; action$.pipe(
      ofType(FETCH_TRENDING_REQUEST),
      mergeMap(async(action) =&gt; {
          const res = await fetchPostStats(action.payload);
          console.log(res);
          res.pipe(
            map(response =&gt; {
              console.log('response', response);
              setTrendingPlaces({trendingPlaces: response});
            })
          )
      })
  );
  </code></pre>
  
  <p>The res was properly printed (showing an observable), but now I get an error: </p>
  
  <blockquote>
    <p>TypeError: Cannot read property 'type' of undefined</p>
  </blockquote>
  
  <p>This is how I create my store in dev: </p>
  
  <pre><code>const createEnhancer = (epicMiddleware) =&gt; {
    const middleware = [ epicMiddleware, createLogger() ];
  
    let enhancer;
    if (getEnvironment() === 'development') {
      enhancer = composeWithDevTools(
        applyMiddleware(...middleware),
        // other store enhancers if any
      );
  
    };
  
  export default (initialState) =&gt; {
    const epicMiddleware = createEpicMiddleware();
    const enhancer = createEnhancer(epicMiddleware);
    const store = createStore(rootReducer, initialState, enhancer);
    epicMiddleware.run(rootEpic);
    return store;
  }
  </code></pre>
  
  <p>Edit note: </p>
  
  <p>This is code executed in NodeJS (SSR).<br>
  I'm struggling with this, don't really understand how this can be so hard to get working without error.<br>
  Can't quite see how the example code will ever work when <code>ajax.getJSON</code> returns a promise, not an Observable...  </p>