Sha256: 61b9908e680723ba6c6ecf6f940a20f3a878320f2ba2f7c4b58f352c82eb995a
Contents?: true
Size: 922 Bytes
Versions: 26
Compression:
Stored size: 922 Bytes
Contents
import statuses from '@bundled-es-modules/statuses' const { message } = statuses export interface SerializedResponse { status: number statusText: string headers: Record<string, any> body: string } export async function serializeResponse( response: Response, ): Promise<SerializedResponse> { const responseClone = response.clone() const responseText = await responseClone.text() // Normalize the response status and status text when logging // since the default Response instance doesn't infer status texts // from status codes. This has no effect on the actual response instance. const responseStatus = responseClone.status || 200 const responseStatusText = responseClone.statusText || message[responseStatus] || 'OK' return { status: responseStatus, statusText: responseStatusText, headers: Object.fromEntries(responseClone.headers.entries()), body: responseText, } }
Version data entries
26 entries across 26 versions & 1 rubygems