checkInsight.js 832 B

1234567891011121314151617181920212223242526272829303132
  1. const axios = require('axios');
  2. const BASE_URL = process.env.INSIGHT_URL;
  3. console.log('---- check start ----- ', BASE_URL);
  4. axios
  5. .get(`${BASE_URL}/api/v1/collections`)
  6. .then(res => {
  7. console.log(res.data);
  8. if (res.data.statusCode === 200) {
  9. console.log('---- Server OK -----');
  10. } else {
  11. throw new Error('');
  12. }
  13. })
  14. .then(err => {
  15. throw new Error(err.message || '---- Server has some error ----');
  16. });
  17. axios
  18. .get(`${BASE_URL}/connect`)
  19. .then(res => {
  20. // if return statusCode mean it's failed. Otherwise it will return html
  21. if (res.data.includes('<html')) {
  22. console.log('---- Client OK -----');
  23. } else {
  24. throw new Error('---- Client has some error ----');
  25. }
  26. })
  27. .catch(err => {
  28. throw new Error(err.message || '---- Client has some error ----');
  29. });