Deprecated
(will be removed after 0.210.0) Import from https://deno.land/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.210.0/http/http_status.ts";
Examples
Example 1
Example 1
import {
Status,
STATUS_TEXT,
} from "https://deno.land/std@0.210.0/http/http_status.ts";
console.log(Status.NotFound); //=> 404
console.log(STATUS_TEXT[Status.NotFound]); //=> "Not Found"
Example 2
Example 2
import { isErrorStatus } from "https://deno.land/std@0.210.0/http/http_status.ts";
const res = await fetch("https://example.com/");
if (isErrorStatus(res.status)) {
// error handling here...
}