variable 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.
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... }