0

I'm brand new in React and working on an existing React-Redux application.

I am trying to redirect the user after an http Post to logout in middleware. The call completes successfully. the server terminates the session and ends up in the promise .then block :

import { push } from 'react-router-redux';
     API.post(`/logout`).then(
        (response) => {
         next(push(`http://www.google.com`));
    },
    (message) => {
        console.warn('logout was not successful');
    }

But it never redirects. Is there another way to do redirect from within the Redux flow ?

JavaHead
  • 571
  • 4
  • 19

1 Answers1

1

Try to create route like in this answer . And don't forget to add an action for redirect and dispatch it if you are doing it in redux way.

<Route path='/go-to-google' component={() => window.location = 'http://www.google.com'}/>

Assigning url to window.location after logout response should also work but it's not a react-redux flow.

Mike Kor
  • 856
  • 5
  • 13