I must have this setup incorrectly because it is not working. If I put a console.log in my if statement it shows up, so I know it is getting to that point, but it is not redirecting. Am I doing this wrong...
...
checkUserAuth = () => {
return fetch(process.env.REACT_APP_API_URL + '/authCheck', {
method: 'post',
headers: {
'Content-Type': 'application/json',
'Authorization': window.localStorage.getItem('token')
},
body: JSON.stringify({
itemid: this.props.itemid
})
})
}
render(){
this.checkUserAuth().then(response => response.json()).then(data => {
if(data === 'false') {
return <Redirect to='/' />
}
}).catch(err => console.log(err))
....