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

x/oak/response.ts>Response#with

A middleware framework for handling HTTP with Deno, Node, Bun and Cloudflare Workers 🐿️ 🦕
Very Popular
Go to Latest
method Response.prototype.with
import { Response } from "https://deno.land/x/oak@v17.0.0/response.ts";

Instead of responding based on the values of the response, explicitly set the response with a Fetch API Response.

If the response is already finalized, this will throw. You can check the .writable property to determine the state if you are unsure.

[!NOTE] This will ignore/override values set in the response like the body, headers and status, meaning things like cookie management and automatic body typing will be ignored.

Parameters

response: globalThis.Response

Instead of responding based on the values of the response, explicitly set the response by providing the initialization to create a Fetch API Response.

If the response is already finalized, this will throw. You can check the .writable property to determine the state if you are unsure.

[!NOTE] This will ignore/override values set in the response like the body, headers and status, meaning things like cookie management and automatic body typing will be ignored.

Parameters

optional
body: BodyInit | null
optional
init: ResponseInit