Files
hoppscotch/packages/hoppscotch-common/src/helpers/findStatusGroup.ts
Anwarul Islam 6fa722df7b chore: hoppscotch-ui improvements (#3497)
Co-authored-by: Liyas Thomas <liyascthomas@gmail.com>
Co-authored-by: Andrew Bastin <andrewbastin.k@gmail.com>
2023-12-06 00:08:44 +05:30

38 lines
909 B
TypeScript

export default function (responseStatus) {
if (responseStatus >= 100 && responseStatus < 200)
return {
name: "informational",
className: "info-response",
}
if (responseStatus >= 200 && responseStatus < 300)
return {
name: "successful",
className: "success-response",
}
if (responseStatus >= 300 && responseStatus < 400)
return {
name: "redirection",
className: "redirect-response",
}
if (responseStatus >= 400 && responseStatus < 500)
return {
name: "client error",
className: "critical-error-response",
}
if (responseStatus >= 500 && responseStatus < 600)
return {
name: "server error",
className: "server-error-response",
}
// this object is a catch-all for when no other objects match and should always be last
return {
name: "unknown",
className: "missing-data-response",
}
}