Skip to main content
Module

x/dax/src/request.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.34.0/src/request.ts";

Result of making a request.

Constructors

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

Properties

readonly
headers: Headers

Response headers.

readonly
ok: boolean

If the response had a 2xx code.

readonly
redirected: boolean

If the response is the result of a redirect.

readonly
response: Response

Raw response.

readonly
status: number

Status code of the response.

readonly
statusText: string

Status text of the response.

readonly
url: string

URL of the response.

Methods

arrayBuffer(): Promise<ArrayBuffer>

Respose body as an array buffer.

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

blob(): Promise<Blob>

Response body as a blog.

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

formData(): Promise<FormData>

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>, options?: PipeOptions): Promise<void>

Pipes the response body to the provided writable stream.

Pipes the response body to a file.

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

Pipes the response body to a file.

text(): Promise<string>

Respose body as text.

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

throwIfNotOk(): void

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.