HTTP Response The Response 
interface is part of the Fetch API and represents a response resource of
fetch().
Constructor  
The Response() constructor creates a new Response instance.
let  response =  new  Response ( body,  init) ; 
        
           
        
           
       
    
      
    Parameters  
name 
type 
optional 
description 
 
 
body 
Blob, BufferSource, FormData, ReadableStream, URLSearchParams, or USVStringtrueThe body of the response. The default value is null. 
 
init 
ResponseInittrueAn optional object that allows setting status and headers of the response. 
 
 
The return type is a Response instance.
ResponseInit 
name 
type 
optional 
description 
 
 
statusnumbertrueThe status code of the response. 
 
statusTextstringtrueThe status message representative of the status code. 
 
headersHeaders or string[][] or Record<string, string>falseThe HTTP headers of the response. 
 
 
Properties  
name 
type 
read only 
description 
 
 
bodyReadableStreamtrueThe getter exposes a ReadableStream of the body contents. 
 
bodyUsedbooleantrueIndicates whether the body content is read. 
 
urlUSVStringtrueThe URL of the response. 
 
headersHeaderstrueThe headers associated with the response. 
 
okbooleantrueIndicates if the response is successful (200-299 status). 
 
redirectedbooleantrueIndicates if the response is the result of a redirect. 
 
statusnumbertrueThe status code of the response 
 
statusTextstringtrueThe status message of the response 
 
typestringtrueThe type of the response. 
 
 
Methods  
name 
description 
 
 
arrayBuffer()Reads the body stream to its completion and returns an ArrayBuffer object. 
 
blob()Reads the body stream to its completion and returns a Blob object. 
 
formData()Reads the body stream to its completion and returns a FormData object. 
 
json()Reads the body stream to its completion, parses it as JSON and returns a JavaScript object. 
 
text()Reads the body stream to its completion and returns a USVString object (text). 
 
clone()Clones the response object. 
 
error()Returns a new response object associated with a network error. 
 
redirect(url: string, status?: number)Creates a new response that redirects to the provided URL. 
 
 
Example  
function  handler ( _req)  { 
  
  const  response =  new  Response ( "<html> Hello </html>" ,  { 
    status:  200 , 
    headers:  { 
      "content-type" :  "text/html" , 
    } , 
  } ) ; 
  console . log ( response. status) ;  
  console . log ( response. headers. get ( "content-type" ) ) ;  
  return  response; 
} 
Deno. serve ( handler) ;