I am new in React js I want to go to home page after successful login react js . Right now I have this function in react and I am using it to go to home.
handleClick(e) {
const tok = this.state.username + ':' + this.state.password;
const hash = Base64.encode(tok);
const Basic = 'Basic ' + hash;
const history = createHashHistory();
Axios.get(ServiceName.BaseUrl + '/auth/login', {withCredentials: true, headers: {'Authorization': Basic}})
.then(res => {
if (res.status == 200) {
/*go to page : "/home"*/
}
})
.catch(err => {
console.log(err);
});
}
or rerdirect