checkInsight.js 603 B

123456789101112131415161718192021
  1. const axios = require('axios');
  2. const BASE_URL = process.env.INSIGHT_URL;
  3. console.log('---- check start ----- ', BASE_URL);
  4. axios.get(`${BASE_URL}/api/v1/asd`).then(res => {
  5. if (res.data.statusCode === 200) {
  6. console.log('---- Server OK -----');
  7. } else {
  8. throw new Error('---- Server has some error ----');
  9. }
  10. });
  11. axios.get(`${BASE_URL}/connect`).then(res => {
  12. // if return statusCode mean it's failed. Otherwise it will return html
  13. if (res.data.includes('<html')) {
  14. console.log('---- Client OK -----');
  15. } else {
  16. throw new Error('---- Client has some error ----');
  17. }
  18. });