import React from 'react' class AsyncAwait extends React.Component { constructor() { super() this.state = {} } async componentDidMount() { const res = await this.context.api.fetch('/logout', { method: 'POST' }).then(() => { this.context.api.environment.getStore().getSource().clear(); this.context.router.push(location.pathname); }); const { ip } = await res.json() await this.setStateAsync({ ipAddress: ip }) } setStateAsync(state) { return new Promise((resolve) => { this.setState(state, resolve) }) } render() { return (
) } } export default AsyncAwait