This Fetch API interface represents the response to a request.

MDN Reference

interface Response {
    body: ReadableStream<Uint8Array>;
    bodyUsed: boolean;
    headers: Headers;
    ok: boolean;
    Redirect: ((url: string, statusCode: 301 | 302) => void);
    redirected: boolean;
    ReturnContent: ((content: string, contentType: string, fileName: string) => void);
    ReturnData: ((content: string, contentType: string, statusCode?: number) => void);
    ReturnFile: ((fileInstance: FileInstance, fileName?: string, mimeType?: string) => void);
    ReturnHtml: ((html: string) => void);
    ReturnText: ((text: string) => void);
    status: number;
    statusText: string;
    type: ResponseType;
    url: string;
    arrayBuffer(): Promise<ArrayBuffer>;
    blob(): Promise<Blob>;
    clone(): Response;
    formData(): Promise<FormData>;
    json(): Promise<any>;
    text(): Promise<string>;
}

Hierarchy

  • Body
  • _Response
    • Response

Properties

body: ReadableStream<Uint8Array>
bodyUsed: boolean
headers: Headers
ok: boolean
Redirect: ((url: string, statusCode: 301 | 302) => void)

Redirects to a new URL with a specified status code.

Type declaration

    • (url, statusCode): void
    • Parameters

      • url: string

        The URL to redirect to.

      • statusCode: 301 | 302

        The HTTP status code for the redirect (301 or 302).

      Returns void

redirected: boolean
ReturnContent: ((content: string, contentType: string, fileName: string) => void)

Sends content as a response with specified content type and file name.

Type declaration

    • (content, contentType, fileName): void
    • Parameters

      • content: string

        The content to return.

      • contentType: string

        The content type of the content.

      • fileName: string

        The file name for the content.

      Returns void

ReturnData: ((content: string, contentType: string, statusCode?: number) => void)

Sends data content with optional status code and content type.

Type declaration

    • (content, contentType, statusCode?): void
    • Parameters

      • content: string

        The data content to return.

      • contentType: string

        The content type of the data.

      • OptionalstatusCode: number

        Optional HTTP status code.

      Returns void

ReturnFile: ((fileInstance: FileInstance, fileName?: string, mimeType?: string) => void)

Sends a file as the response.

Type declaration

    • (fileInstance, fileName?, mimeType?): void
    • Parameters

      • fileInstance: FileInstance

        The file instance to return.

      • OptionalfileName: string

        Optional file name to use for download.

      • OptionalmimeType: string

        Optional MIME type of the file.

      Returns void

ReturnHtml: ((html: string) => void)

Sends HTML content as the response.

Type declaration

    • (html): void
    • Parameters

      • html: string

        The HTML content to return.

      Returns void

ReturnText: ((text: string) => void)

Sends plain text as the response.

Type declaration

    • (text): void
    • Parameters

      • text: string

        The text content to return.

      Returns void

status: number
statusText: string
type: ResponseType
url: string

Methods

  • Returns Promise<ArrayBuffer>

  • Returns Promise<Blob>

  • Returns Promise<FormData>

  • Returns Promise<any>

  • Returns Promise<string>