diff --git a/app/components/shared/Header/Header.jsx b/app/components/shared/Header/Header.jsx index 045f2eb..0a068f0 100644 --- a/app/components/shared/Header/Header.jsx +++ b/app/components/shared/Header/Header.jsx @@ -7,13 +7,20 @@ import FontIcon from 'material-ui/FontIcon'; import { browserHistory } from 'react-router'; import CountDown from './countdown.js' import styles from './header.css'; -import { callVaultApi } from '../../shared/VaultUtils.jsx' +import { callVaultApi } from '../../shared/VaultUtils.jsx'; +import Snackbar from 'material-ui/Snackbar'; + var logout = () => { window.localStorage.removeItem('vaultAccessToken'); browserHistory.push('/login'); } +function snackBarMessage(message) { + let ev = new CustomEvent("snackbar", { detail: { message: message } }); + document.dispatchEvent(ev); +} + class Header extends React.Component { constructor(props) { super(props); @@ -33,6 +40,15 @@ class Header extends React.Component { this.setState({ version: resp.data.version, }); + }) + .catch((error) => { + if (error.response.status === 429) { + this.setState({ + version: error.response.data.version, + }); + } else { + snackBarMessage(error); + } }); } diff --git a/src/health.js b/src/health.js deleted file mode 100644 index 50cf4be..0000000 --- a/src/health.js +++ /dev/null @@ -1,13 +0,0 @@ -exports.getHealth = function (req, resp) { - let endpoint = `/v1/sys/health`; - let vaultAddr = decodeURI(req.query['vaultaddr']); - let config = { headers: { 'X-Vault-Token': req.query['token'] } } - - axios.get(`${vaultAddr}${endpoint}`, config) - .then((resp) => { - res.json(resp.data.data); - }) - .catch((err) => { - console.error(err.stack); - }); -} \ No newline at end of file diff --git a/src/vaultapi.js b/src/vaultapi.js index 435ed9a..e4337ef 100644 --- a/src/vaultapi.js +++ b/src/vaultapi.js @@ -18,14 +18,12 @@ exports.callMethod = function (req, res) { headers: req.headers, data: req.body } - //console.log(config); + axios.request(config) .then(function (resp) { res.json(resp.data); }) .catch(function (err) { - //console.error(err.response.data); - //console.error(err.stack); res.status(err.response.status).send(err.response.data); }); }; \ No newline at end of file