STATUS_CODE

import { STATUS_CODE } from "jsr:@ende/http";

variable

const STATUS_CODE: { … }

Contains the STATUS_CODE object which contains standard HTTP status codes and provides several type guards for handling status codes with type safety.

Example: The status code and status text

import {
  STATUS_CODE,
  STATUS_TEXT,
} from "@ende/http/status";

console.log(STATUS_CODE.NotFound); // Returns 404
console.log(STATUS_TEXT[STATUS_CODE.NotFound]); // Returns "Not Found"

Example: Checking the status code type

import { isErrorStatus } from "@ende/http/status";

const res = await fetch("https://example.com/");

if (isErrorStatus(res.status)) {
  // error handling here...
}

await res.body?.cancel();

Properties

Continue

Continue: number

RFC 7231, 6.2.1

SwitchingProtocols

SwitchingProtocols: number

RFC 7231, 6.2.2

Processing

Processing: number

RFC 2518, 10.1

EarlyHints

EarlyHints: number

RFC 8297 *

OK

OK: number

RFC 7231, 6.3.1

Created

Created: number

RFC 7231, 6.3.2

Accepted

Accepted: number

RFC 7231, 6.3.3

NonAuthoritativeInfo

NonAuthoritativeInfo: number

RFC 7231, 6.3.4

NoContent

NoContent: number

RFC 7231, 6.3.5

ResetContent

ResetContent: number

RFC 7231, 6.3.6

PartialContent

PartialContent: number

RFC 7233, 4.1

MultiStatus

MultiStatus: number

RFC 4918, 11.1

AlreadyReported

AlreadyReported: number

RFC 5842, 7.1

IMUsed

IMUsed: number

RFC 3229, 10.4.1

MultipleChoices

MultipleChoices: number

RFC 7231, 6.4.1

MovedPermanently

MovedPermanently: number

RFC 7231, 6.4.2

Found

Found: number

RFC 7231, 6.4.3

SeeOther

SeeOther: number

RFC 7231, 6.4.4

NotModified

NotModified: number

RFC 7232, 4.1

UseProxy

UseProxy: number

RFC 7231, 6.4.5

TemporaryRedirect

TemporaryRedirect: number

RFC 7231, 6.4.7

PermanentRedirect

PermanentRedirect: number

RFC 7538, 3

BadRequest

BadRequest: number

RFC 7231, 6.5.1

Unauthorized

Unauthorized: number

RFC 7235, 3.1

PaymentRequired

PaymentRequired: number

RFC 7231, 6.5.2

Forbidden

Forbidden: number

RFC 7231, 6.5.3

NotFound

NotFound: number

RFC 7231, 6.5.4

MethodNotAllowed

MethodNotAllowed: number

RFC 7231, 6.5.5

NotAcceptable

NotAcceptable: number

RFC 7231, 6.5.6

ProxyAuthRequired

ProxyAuthRequired: number

RFC 7235, 3.2

RequestTimeout

RequestTimeout: number

RFC 7231, 6.5.7

Conflict

Conflict: number

RFC 7231, 6.5.8

Gone

Gone: number

RFC 7231, 6.5.9

LengthRequired

LengthRequired: number

RFC 7231, 6.5.10

PreconditionFailed

PreconditionFailed: number

RFC 7232, 4.2

ContentTooLarge

ContentTooLarge: number

RFC 7231, 6.5.11

URITooLong

URITooLong: number

RFC 7231, 6.5.12

UnsupportedMediaType

UnsupportedMediaType: number

RFC 7231, 6.5.13

RangeNotSatisfiable

RangeNotSatisfiable: number

RFC 7233, 4.4

ExpectationFailed

ExpectationFailed: number

RFC 7231, 6.5.14

Teapot

Teapot: number

RFC 7168, 2.3.3

MisdirectedRequest

MisdirectedRequest: number

RFC 7540, 9.1.2

UnprocessableEntity

UnprocessableEntity: number

RFC 4918, 11.2

Locked

Locked: number

RFC 4918, 11.3

FailedDependency

FailedDependency: number

RFC 4918, 11.4

TooEarly

TooEarly: number

RFC 8470, 5.2

UpgradeRequired

UpgradeRequired: number

RFC 7231, 6.5.15

PreconditionRequired

PreconditionRequired: number

RFC 6585, 3

TooManyRequests

TooManyRequests: number

RFC 6585, 4

RequestHeaderFieldsTooLarge

RequestHeaderFieldsTooLarge: number

RFC 6585, 5

UnavailableForLegalReasons

UnavailableForLegalReasons: number

RFC 7725, 3

InternalServerError

InternalServerError: number

RFC 7231, 6.6.1

NotImplemented

NotImplemented: number

RFC 7231, 6.6.2

BadGateway

BadGateway: number

RFC 7231, 6.6.3

ServiceUnavailable

ServiceUnavailable: number

RFC 7231, 6.6.4

GatewayTimeout

GatewayTimeout: number

RFC 7231, 6.6.5

HTTPVersionNotSupported

HTTPVersionNotSupported: number

RFC 7231, 6.6.6

VariantAlsoNegotiates

VariantAlsoNegotiates: number

RFC 2295, 8.1

InsufficientStorage

InsufficientStorage: number

RFC 4918, 11.5

LoopDetected

LoopDetected: number

RFC 5842, 7.2

NotExtended

NotExtended: number

RFC 2774, 7

NetworkAuthenticationRequired

NetworkAuthenticationRequired: number

RFC 6585, 6

Source