score:2

import { useHistory} from "react-router-dom";

const history = useHistory();

.then(res => {
  localStorage.setItem('api_key', res.data.api_key);
  history.push('dashboard');
})

Related Query

More Query from same tag