api.js refactor using classes (#250)

Refactor api.js into an api module where endpoint specific models can be imported and used in components.
This commit is contained in:
Michael Abashian
2019-06-07 15:48:09 -04:00
committed by GitHub
parent a8c51670af
commit 2ae93261d1
51 changed files with 839 additions and 727 deletions

View File

@@ -15,6 +15,7 @@ import styled from 'styled-components';
import { RootDialog } from './contexts/RootDialog';
import { withNetwork } from './contexts/Network';
import { Config } from './contexts/Config';
import { RootAPI } from './api';
import AlertModal from './components/AlertModal';
import About from './components/About';
@@ -56,9 +57,9 @@ class App extends Component {
}
async onLogout () {
const { api, handleHttpError } = this.props;
const { handleHttpError } = this.props;
try {
await api.logout();
await RootAPI.logout();
window.location.replace('/#/login');
} catch (err) {
handleHttpError(err);