Skip to main content
Module

x/dax/mod.ts>RequestResult

Cross platform shell tools for Deno inspired by zx.
Very Popular
Go to Latest
class RequestResult
import { RequestResult } from "https://deno.land/x/dax@0.24.0/mod.ts";

Result of making a request.

Constructors

new
RequestResult(opts: { response: Response; originalUrl: string; progressBar: ProgressBar | undefined; })

Properties

readonly
headers

Response headers.

readonly
ok

If the response had a 2xx code.

readonly
redirected

If the response is the result of a redirect.

readonly
response

Raw response.

readonly
status

Status code of the response.

readonly
statusText

Status text of the response.

readonly
url

URL of the response.

Methods

Respose body as an array buffer.

Note: Returns undefined when .noThrow(404) and status code is 404.

Response body as a blog.

Note: Returns undefined when .noThrow(404) and status code is 404.

Response body as a form data.

Note: Returns undefined when .noThrow(404) and status code is 404.

json<TResult = any>(): Promise<TResult>

Respose body as JSON.

Note: Returns undefined when .noThrow(404) and status code is 404.

pipeThrough<T>(transform: { writable: WritableStream<Uint8Array>; readable: ReadableStream<T>; }): ReadableStream<T>

Pipes the response body through the provided transform.

pipeTo(dest: WritableStream<Uint8Array>)

Pipes the response body to the provided writable stream.

pipeToPath(options?: Deno.WriteFileOptions): Promise<string>

Pipes the response body to a file.

pipeToPath(path?: string | URL | undefined, options?: Deno.WriteFileOptions): Promise<string>

Pipes the response body to a file.

Respose body as text.

Note: Returns undefined when .noThrow(404) and status code is 404.

Throws if the response doesn't have a 2xx code.

This might be useful if the request was built with .noThrow(), but otherwise this is called automatically for any non-2xx response codes.