Skip to main content
Using Deno in production at your company? Earn free Deno merch.
Give us feedback
Module

x/deno/ext/fetch/lib.deno_fetch.d.ts>Response

A modern runtime for JavaScript and TypeScript.
Go to Latest
class Response
implements Body
import { Response } from "https://deno.land/x/deno@v1.28.0/ext/fetch/lib.deno_fetch.d.ts";

This Fetch API interface represents the response to a request.

Constructors

new
Response(body?: BodyInit | null, init?: ResponseInit)

Properties

readonly
body: ReadableStream<Uint8Array> | null

A simple getter used to expose a ReadableStream of the body contents.

readonly
bodyUsed: boolean

Stores a Boolean that declares whether the body has been used in a response yet.

readonly
headers: Headers
readonly
ok: boolean
readonly
redirected: boolean
readonly
status: number
readonly
statusText: string
readonly
trailer: Promise<Headers>
readonly
type: ResponseType
readonly
url: string

Methods

arrayBuffer(): Promise<ArrayBuffer>

Takes a Response stream and reads it to completion. It returns a promise that resolves with an ArrayBuffer.

blob(): Promise<Blob>

Takes a Response stream and reads it to completion. It returns a promise that resolves with a Blob.

formData(): Promise<FormData>

Takes a Response stream and reads it to completion. It returns a promise that resolves with a FormData object.

json(): Promise<any>

Takes a Response stream and reads it to completion. It returns a promise that resolves with the result of parsing the body text as JSON.

text(): Promise<string>

Takes a Response stream and reads it to completion. It returns a promise that resolves with a USVString (text).

Static Methods

json(data: unknown, init?: ResponseInit): Response
redirect(url: string | URL, status?: number): Response