I have a login function like below.
login(){
    var data = {
        client_id: 2,
        client_secret: 'ispGH4SmkEeV4i5Tz9NoI0RSzid5mciG5ecw011f',
        grant_type: 'password',
        username: this.state.email,
        password: this.state.password
    }
    fetch('http://127.0.0.1:8000/oauth/token', {
        method: 'POST',
        headers: {
            'Accept': 'application/json',
            'Content-Type': 'application/json',
        },
        body: JSON.stringify(data)
    })
    .then((response) => response.json())
    .then((responseData) => {
        Auth.setToken(responseData.access_token,responseData.expires_in+ Date.now());
        this.props.history.push("/dashboard");
    })
}
I am getting below error.
UPDATE
I read this question and try to use withRouter like below
import React from "react";
import { withRouter } from "react-router-dom";
class Login extends React.Component {
  ...
  login() {
    this.props.history.push("/dashboard");
  }
  ...
}
export default withRouter(Login);
But I am getting below error.


 
    