add api status check
This commit is contained in:
@@ -2,14 +2,14 @@
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico" />
|
||||
<link rel="shortcut icon" href="favicon.ico" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<meta name="theme-color" content="#000000" />
|
||||
<!--
|
||||
manifest.json provides metadata used when your web app is installed on a
|
||||
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
|
||||
-->
|
||||
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
|
||||
<link rel="manifest" href="manifest.json" />
|
||||
<!--
|
||||
Notice the use of %PUBLIC_URL% in the tags above.
|
||||
It will be replaced with the URL of the `public` folder during the build.
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
const apiStatusCheck = (req, res) => {
|
||||
res.send({status: 1});
|
||||
res.json({status: 1});
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
|
||||
10
server.js
10
server.js
@@ -1,20 +1,20 @@
|
||||
'use strict';
|
||||
|
||||
const express = require("express");
|
||||
const routes = require('./routes');
|
||||
const path = require('path');
|
||||
const routes = require('./routes');
|
||||
|
||||
const app = express();
|
||||
const port = process.env.PORT || 5000;
|
||||
|
||||
|
||||
app.use('/api', routes);
|
||||
|
||||
//Static file declaration
|
||||
app.use(express.static(path.join(__dirname, 'client/build')));
|
||||
|
||||
//production mode
|
||||
if(process.env.NODE_ENV === 'production') {
|
||||
app.use(express.static(path.join(__dirname, 'client/build')));
|
||||
//
|
||||
app.get('*', (req, res) => {
|
||||
res.sendfile(path.join(__dirname = 'client/build/index.html'));
|
||||
});
|
||||
@@ -22,9 +22,7 @@ if(process.env.NODE_ENV === 'production') {
|
||||
|
||||
//build mode
|
||||
app.get('*', (req, res) => {
|
||||
res.sendFile(path.join(__dirname+'/client/public/index.html'));
|
||||
res.sendFile(path.join(__dirname + '/client/public/index.html'));
|
||||
});
|
||||
|
||||
|
||||
app.use('/api', routes);
|
||||
app.listen(port, () => console.log(`App running on port ${port}!`));
|
||||
|
||||
Reference in New Issue
Block a user