I have a react page with the method below. When I click the button a method studentApproval() is called. This method gets hit but I want a redirection to another page once this is done. No redirection is happening. How can I make this redirection work?
This line is not working.
this.props.history.push(STUDENT_FORMS_URL)
Button that gets clicked on the page
<Button
onClick={() => this.studentApproval()}
className="next-button"
>
Approve<Icon>chevron_right</Icon>
</Button>
This resides in another file.
export const STUDENT_FORMS_URL = '/student-forms';
Method that gets hit on the click of the button.
studentApproval(){
AXIOS.post(`${API}/student-forms/check-request`, {
action: "APPROVE",
studentFormId: myId
},{
headers: {
"Content-Type": "application/json"
}
}).then(res => {
this.props.history.push(STUDENT_FORMS_URL)
}).catch(err => {
console.log(err);
});
}