Browse Source

test error

nameczz 4 years ago
parent
commit
93fdd5a1cc
1 changed files with 8 additions and 7 deletions
  1. 8 7
      checkInsight.js

+ 8 - 7
checkInsight.js

@@ -3,19 +3,20 @@ const axios = require('axios');
 const BASE_URL = process.env.INSIGHT_URL;
 console.log('---- check start ----- ', BASE_URL);
 
-axios.get(`${BASE_URL}/api/v1/asd`).then(res => {
-  if (res.data.statusCode === 200) {
+const check = async () => {
+  const clientRes = await axios.get(`${BASE_URL}/connect`);
+  const serverRes = await axios.get(`${BASE_URL}/api/v1/asd`);
+  if (serverRes.data.statusCode === 200) {
     console.log('---- Server OK -----');
   } else {
     throw new Error('---- Server has some error ----');
   }
-});
 
-axios.get(`${BASE_URL}/connect`).then(res => {
-  // if return statusCode mean it's failed. Otherwise it will return html
-  if (res.data.includes('<html')) {
+  if (clientRes.data.includes('<html')) {
     console.log('---- Client OK -----');
   } else {
     throw new Error('---- Client has some error ----');
   }
-});
+};
+
+check();