add api status check

This commit is contained in:
Bilal Catic
2019-05-24 10:14:41 +02:00
parent ac6a738749
commit c0788d7a43
4 changed files with 41 additions and 16 deletions

View File

@@ -1,9 +1,36 @@
import React from 'react';
import React, { Component } from 'react';
export default function Home () {
return (
<div>
<h3>Sima Space - CRM Integration</h3>
</div>
);
class Home extends Component {
state = {
apiStatus: 'loading',
};
componentDidMount() {
fetch('/api')
.then(response => response.json())
.then(result => {
console.log(result);
if (result.status === 1) {
this.setState({apiStatus: 'working'});
} else {
this.setState({apiStatus: 'NOT WORKING !'});
}
})
.catch(err => {
this.setState({apiStatus: `ERROR : ${err}`});
})
}
render () {
const {apiStatus} = this.state;
return (
<div>
<h3>CRM Integration</h3>
<hr/>
<h5>Integration API Status : {apiStatus}</h5>
</div>
);
}
}
export default Home;