Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

std/http/http_status.ts

Deno standard library
Go to Latest
The Standard Library has been moved to JSR. See the blog post for details.
Deprecated

(will be removed after 0.210.0) Import from std/http/status.ts instead.

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

import * as mod from "https://deno.land/std@0.205.0/http/http_status.ts";

Examples

Example 1

import {
  Status,
  STATUS_TEXT,
} from "https://deno.land/std@0.205.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.205.0/http/http_status.ts";

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

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

Variables

v
isErrorStatus
deprecated
v
isRedirectStatus
deprecated
v
Status
deprecated
v
STATUS_TEXT
deprecated

Type Aliases

T
ErrorStatus
deprecated
T
RedirectStatus
deprecated
T
Status
deprecated
T
SuccessfulStatus
deprecated