findStatusGroup.js 896 B

12345678910111213141516171819202122232425262728293031323334353637
  1. export default function (responseStatus) {
  2. if (responseStatus >= 100 && responseStatus < 200)
  3. return {
  4. name: "informational",
  5. className: "info-response",
  6. }
  7. if (responseStatus >= 200 && responseStatus < 300)
  8. return {
  9. name: "successful",
  10. className: "success-response",
  11. }
  12. if (responseStatus >= 300 && responseStatus < 400)
  13. return {
  14. name: "redirection",
  15. className: "redir-response",
  16. }
  17. if (responseStatus >= 400 && responseStatus < 500)
  18. return {
  19. name: "client error",
  20. className: "cl-error-response",
  21. }
  22. if (responseStatus >= 500 && responseStatus < 600)
  23. return {
  24. name: "server error",
  25. className: "sv-error-response",
  26. }
  27. // this object is a catch-all for when no other objects match and should always be last
  28. return {
  29. name: "unknown",
  30. className: "missing-data-response",
  31. }
  32. }