Meu código esta exatamente como do instrutor:
import ReduxRouterEngine from "electrode-redux-router-engine";
import {routes} from "../../client/routes";
import {createStore, applyMiddleware} from "redux";
import rootReducer from "../../client/reducers";
import { thunkMiddleware } from 'redux-thunk';
import { notificacao } from '../../client/reducers/header';
import TimelineApi from '../../client/logicas/TimelineApi';
function createReduxStore(req, match) { // eslint-disable-line
const estadoInicial = {
timeline: [],
notificacao: ''
}
const store = createStore(rootReducer, estadoInicial, applyMiddleware(thunkMiddleware));
const promise = store.dispatch(TimelineApi.lista(`http://localhost:8080/api/fotos?X-AUTH-TOKEN=${req.state['auth-token']}`));
return promise.then(() => store);
}
//
// This function is exported as the content for the webapp plugin.
//
// See config/default.json under plugins.webapp on specifying the content.
//
// When the Web server hits the routes handler installed by the webapp plugin, it
// will call this function to retrieve the content for SSR if it's enabled.
//
//
module.exports = (req) => {
const app = req.server && req.server.app || req.app;
if (!app.routesEngine) {
app.routesEngine = new ReduxRouterEngine({routes, createReduxStore});
}
return app.routesEngine.render(req);
};
mas recebo esse erro:
Electrode ReduxRouterEngine Error: TypeError: middleware is not a function
at /Users/jeffprestes/projetos/projeto-instalura-ssr-codigo-ponto-partida/node_modules/redux/lib/redux.js:621:16
at Array.map (<anonymous>)
at /Users/jeffprestes/projetos/projeto-instalura-ssr-codigo-ponto-partida/node_modules/redux/lib/redux.js:620:31
at createStore (/Users/jeffprestes/projetos/projeto-instalura-ssr-codigo-ponto-partida/node_modules/redux/lib/redux.js:85:33)
at ReduxRouterEngine.createReduxStore (/Users/jeffprestes/projetos/projeto-instalura-ssr-codigo-ponto-partida/src/server/views/index-view.js:18:17)
at ReduxRouterEngine._handleRender (/Users/jeffprestes/projetos/projeto-instalura-ssr-codigo-ponto-partida/node_modules/electrode-redux-router-engine/lib/redux-router-engine.js:124:59)
at _matchRoute.then (/Users/jeffprestes/projetos/projeto-instalura-ssr-codigo-ponto-partida/node_modules/electrode-redux-router-engine/lib/redux-router-engine.js:85:21)
at bound (domain.js:395:14)
at runBound (domain.js:408:12)
at tryCatcher (/Users/jeffprestes/projetos/projeto-instalura-ssr-codigo-ponto-partida/node_modules/bluebird/js/release/util.js:16:23)
at Promise._settlePromiseFromHandler (/Users/jeffprestes/projetos/projeto-instalura-ssr-codigo-ponto-partida/node_modules/bluebird/js/release/promise.js:512:31)
at Promise._settlePromise (/Users/jeffprestes/projetos/projeto-instalura-ssr-codigo-ponto-partida/node_modules/bluebird/js/release/promise.js:569:18)
at Promise._settlePromiseCtx (/Users/jeffprestes/projetos/projeto-instalura-ssr-codigo-ponto-partida/node_modules/bluebird/js/release/promise.js:606:10)
at _drainQueueStep (/Users/jeffprestes/projetos/projeto-instalura-ssr-codigo-ponto-partida/node_modules/bluebird/js/release/async.js:142:12)
at _drainQueue (/Users/jeffprestes/projetos/projeto-instalura-ssr-codigo-ponto-partida/node_modules/bluebird/js/release/async.js:131:9)
at Async._drainQueues (/Users/jeffprestes/projetos/projeto-instalura-ssr-codigo-ponto-partida/node_modules/bluebird/js/release/async.js:147:5)
(node:32807) [DEP0097] DeprecationWarning: Using a domain property in MakeCallback is deprecated. Use the async_context variant of MakeCallback or the AsyncResource class instead.