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

x/dax/src/request.ts>RequestBuilder#noThrow

Cross-platform shell tools for Deno and Node.js inspired by zx.
Very Popular
Go to Latest
method RequestBuilder.prototype.noThrow
import { RequestBuilder } from "https://deno.land/x/dax@0.39.1/src/request.ts";

Do not throw if a non-2xx status code is received.

By default the request builder will throw when receiving a non-2xx status code. Specify this to have it not throw.

Parameters

optional
value: boolean

Do not throw if a non-2xx status code is received except for these excluded provided status codes.

This overload may be especially useful when wanting to ignore 404 status codes and have it return undefined instead. For example:

const data = await $.request(`https://crates.io/api/v1/crates/${crateName}`)
  .noThrow(404)
  .json<CratesIoMetadata | undefined>();

Note, use multiple arguments to ignore multiple status codes (ex. .noThrow(400, 404)) as multiple calls to .noThrow() will overwrite the previous.

Parameters

exclusionStatusCode: number
...additional: number[]