Skip to main content
Deno 2 is finally here 🎉️
Learn more
Latest
import * as denogres from "https://deno.land/x/denogres@v4.0.1/vendor/deno.land/std@0.173.0/http/http_status.ts";

Contains the enum Status which enumerates standard HTTP status codes and provides several type guards for handling status codes with type safety.

Examples

Example 1

import {
  Status,
  STATUS_TEXT,
} from "https://deno.land/std@0.224.0/http/http_status.ts";

console.log(Status.NotFound); //=> 404
console.log(STATUS_TEXT[Status.NotFound]); //=> "Not Found"
import { isErrorStatus } from "https://deno.land/std@0.224.0/http/http_status.ts";

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

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

Enums

Standard HTTP status codes.

Variables

A record of all the status codes text.

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.

A type guard that determines if the status code is successful.

Type Aliases

An HTTP status that is a client error (4XX).

An HTTP status that is an error (4XX and 5XX).

An HTTP status that is a informational (1XX).

An HTTP status that is a redirect (3XX).

An HTTP status that is a server error (5XX).

An HTTP status that is a success (2XX).