Contains the STATUS_CODE object which contains standard HTTP
status codes and provides several type guards for handling status codes
with type safety.
Examples
Example 1
Example 1
import { STATUS_CODE, STATUS_TEXT, } from "@std/http/status"; console.log(STATUS_CODE.NotFound); // Returns 404 console.log(STATUS_TEXT[STATUS_CODE.NotFound]); // Returns "Not Found"
Example 2
Example 2
import { isErrorStatus } from "@std/http/status"; const res = await fetch("https://example.com/"); if (isErrorStatus(res.status)) { // error handling here... }
Functions
A type guard that determines if the status code is a client error.
A type guard that determines if the status code is an error.
A type guard that determines if the status code is informational.
A type guard that determines if the status code is a redirection.
A type guard that determines if the status code is a server error.
Returns whether the provided number is a valid HTTP status code.
A type guard that determines if the status code is successful.
Type Aliases
| STATUS_CODE.Unauthorized
| STATUS_CODE.PaymentRequired
| STATUS_CODE.Forbidden
| STATUS_CODE.NotFound
| STATUS_CODE.MethodNotAllowed
| STATUS_CODE.NotAcceptable
| STATUS_CODE.ProxyAuthRequired
| STATUS_CODE.RequestTimeout
| STATUS_CODE.Conflict
| STATUS_CODE.Gone
| STATUS_CODE.LengthRequired
| STATUS_CODE.PreconditionFailed
| STATUS_CODE.ContentTooLarge
| STATUS_CODE.URITooLong
| STATUS_CODE.UnsupportedMediaType
| STATUS_CODE.RangeNotSatisfiable
| STATUS_CODE.ExpectationFailed
| STATUS_CODE.Teapot
| STATUS_CODE.MisdirectedRequest
| STATUS_CODE.UnprocessableEntity
| STATUS_CODE.Locked
| STATUS_CODE.FailedDependency
| STATUS_CODE.UpgradeRequired
| STATUS_CODE.PreconditionRequired
| STATUS_CODE.TooManyRequests
| STATUS_CODE.RequestHeaderFieldsTooLarge
| STATUS_CODE.UnavailableForLegalReasons
An HTTP status that is a client error (4XX).
An HTTP status that is an error (4XX and 5XX).
| STATUS_CODE.SwitchingProtocols
| STATUS_CODE.Processing
| STATUS_CODE.EarlyHints
An HTTP status that is a informational (1XX).
| STATUS_CODE.MovedPermanently
| STATUS_CODE.Found
| STATUS_CODE.SeeOther
| STATUS_CODE.UseProxy
| STATUS_CODE.TemporaryRedirect
| STATUS_CODE.PermanentRedirect
An HTTP status that is a redirect (3XX).
| STATUS_CODE.NotImplemented
| STATUS_CODE.BadGateway
| STATUS_CODE.ServiceUnavailable
| STATUS_CODE.GatewayTimeout
| STATUS_CODE.HTTPVersionNotSupported
| STATUS_CODE.VariantAlsoNegotiates
| STATUS_CODE.InsufficientStorage
| STATUS_CODE.LoopDetected
| STATUS_CODE.NotExtended
| STATUS_CODE.NetworkAuthenticationRequired
An HTTP status that is a server error (5XX).
An HTTP status code.
An HTTP status text.
| STATUS_CODE.Created
| STATUS_CODE.Accepted
| STATUS_CODE.NonAuthoritativeInfo
| STATUS_CODE.NoContent
| STATUS_CODE.ResetContent
| STATUS_CODE.PartialContent
| STATUS_CODE.MultiStatus
| STATUS_CODE.AlreadyReported
| STATUS_CODE.IMUsed
An HTTP status that is a success (2XX).
Variables
Contains the STATUS_CODE object which contains standard HTTP
status codes and provides several type guards for handling status codes
with type safety.
- Accepted: numberNo documentation available
- AlreadyReported: numberNo documentation available
- BadGateway: numberNo documentation available
- BadRequest: numberNo documentation available
- Conflict: numberNo documentation available
- ContentTooLarge: numberNo documentation available
- Continue: numberNo documentation available
- Created: numberNo documentation available
- EarlyHints: numberNo documentation available
- ExpectationFailed: numberNo documentation available
- FailedDependency: numberNo documentation available
- Forbidden: numberNo documentation available
- Found: numberNo documentation available
- GatewayTimeout: numberNo documentation available
- Gone: numberNo documentation available
- HTTPVersionNotSupported: numberNo documentation available
- IMUsed: numberNo documentation available
- InsufficientStorage: numberNo documentation available
- InternalServerError: numberNo documentation available
- LengthRequired: numberNo documentation available
- Locked: numberNo documentation available
- LoopDetected: numberNo documentation available
- MethodNotAllowed: numberNo documentation available
- MisdirectedRequest: numberNo documentation available
- MovedPermanently: numberNo documentation available
- MultiStatus: numberNo documentation available
- MultipleChoices: numberNo documentation available
- NetworkAuthenticationRequired: numberNo documentation available
- NoContent: numberNo documentation available
- NonAuthoritativeInfo: numberNo documentation available
- NotAcceptable: numberNo documentation available
- NotExtended: numberNo documentation available
- NotFound: numberNo documentation available
- NotImplemented: numberNo documentation available
- NotModified: numberNo documentation available
- OK: numberNo documentation available
- PartialContent: numberNo documentation available
- PaymentRequired: numberNo documentation available
- PermanentRedirect: numberNo documentation available
- PreconditionFailed: numberNo documentation available
- PreconditionRequired: numberNo documentation available
- Processing: numberNo documentation available
- ProxyAuthRequired: numberNo documentation available
- RangeNotSatisfiable: numberNo documentation available
- RequestHeaderFieldsTooLarge: numberNo documentation available
- RequestTimeout: numberNo documentation available
- ResetContent: numberNo documentation available
- SeeOther: numberNo documentation available
- ServiceUnavailable: numberNo documentation available
- SwitchingProtocols: numberNo documentation available
- Teapot: numberNo documentation available
- TemporaryRedirect: numberNo documentation available
- TooEarly: numberNo documentation available
- TooManyRequests: numberNo documentation available
- URITooLong: numberNo documentation available
- Unauthorized: numberNo documentation available
- UnavailableForLegalReasons: numberNo documentation available
- UnprocessableEntity: numberNo documentation available
- UnsupportedMediaType: numberNo documentation available
- UpgradeRequired: numberNo documentation available
- UseProxy: numberNo documentation available
- VariantAlsoNegotiates: numberNo documentation available
A record of all the status codes text.