Skip to main content

Function: encodeResponse()

encodeResponse(response, encodeHeaders?, encodeBody?): Promise<any>

Defined in: web-api-encoding.ts:186

Encode Response object to an intermediate form that can be stringified to JSON

Note: This consumes the response body. If you need the original Response after encoding, clone it before calling this function: response.clone()

Why callbacks? Users can safely ignore the optional encodeHeaders and encodeBody callbacks. They are used internally to enable cycle/alias tracking when this object is embedded in another object.

Parameters

response

Response

The Response to encode

encodeHeaders?

(h) => any

Optional callback to encode Headers (default: inline encoding)

encodeBody?

(b) => any

Optional callback to encode body (default: inline encoding)

Returns

Promise<any>