после setState
, я хочу вызвать service.logout()
, затем Auth.logout()
функцию,
componentWillMount() {
if (!(this.Auth.loggedIn())){
this.props.history.replace('/login');
} else {
this.setState({token : this.Auth.getToken()}).then(service.logout(this.state.token)).then( this.Auth.logout())
// console.log('token',this.state.token)
}
}
но я получаю error
вот так,
TypeError: Cannot read property 'then' of undefined
Logout.componentWillMount
src/components/auth/Logout.js:20
17 | if (!(this.Auth.loggedIn())){
18 | this.props.history.replace('/login');
19 | } else {
> 20 | this.setState({token : this.Auth.getToken()}).then(service.logout(this.state.token)).then( this.Auth.logout())
21 | // console.log('token',this.state.token)
22 |
23 | }