after I receive the response from the backend and based on it trying to redirect to a different route but no matter what i do the app redirects to the signin route and display my http request on the link although it is a post request
i tried getting the response and do nothing with it (i did only fetch (no then) and got the response ) it worked but when try to go to different the problem happens and i know for sure that response is getting back
onSubmitSignIn = () => {
fetch('http://localhost:3000/signin' , {
method: 'post' ,
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
email: this.state.signInEmail,
password: this.state.signInPassword
})
})
.then(response => response.json())
.then(data => {
if (data === 'success') {
this.props.onRouteChange('home');
}
})
}
onRouteChange= (route) => {
if (route==='signout'){
this.setState({isSignedIn:false})
}
else if (route ==='home') {
this.setState({isSignedIn:true})
}
this.setState({route:route})
}
render() {
return (
<div className="App">
<Navigation isSignedIn={this.state.isSignedIn} onRouteChange = {this.onRouteChange}/>
<ParticlesBg color="#282c34" num={200} type="cobweb" bg={true} />
{ this.state.route === 'home' ?
<div> <Logo />
<Rank />
<ImgLinkForm onInputChange={this.onInputChange} onSubmit={this.onSubmit}/>
<Facerec box={this.state.box} imageurl={this.state.imageurl} />
</div>
:
(this.state.route === 'signin' ? <Signin onRouteChange = {this.onRouteChange} />
: <SignUp loadUser={this.loadUser} onRouteChange = {this.onRouteChange} />
)
}
</div>
);}