Class: ResponseSync
Defined in: response-sync.ts:43
Synchronous Response wrapper
Provides synchronous body access methods (.text(), .json(), .arrayBuffer()) by storing the body separately in serializable format.
Constructors
Constructor
new ResponseSync(
body?,init?):ResponseSync
Defined in: response-sync.ts:56
Create a ResponseSync
Parameters
body?
SerializableBody
Serializable body (string, ArrayBuffer, or plain object)
init?
ResponseInit
Response options (status, headers, etc.)
Returns
ResponseSync
Properties
_response
_response:
Response
Defined in: response-sync.ts:45
Internal Response object (metadata only, no body stream)
body
body:
SerializableBody
Defined in: response-sync.ts:48
Serializable body (string, ArrayBuffer, or plain object)
Accessors
headers
Get Signature
get headers():
Headers
Defined in: response-sync.ts:151
Response headers
Returns
Headers
ok
Get Signature
get ok():
boolean
Defined in: response-sync.ts:156
Whether response is successful (status 200-299)
Returns
boolean
redirected
Get Signature
get redirected():
boolean
Defined in: response-sync.ts:161
Whether response was redirected
Returns
boolean
status
Get Signature
get status():
number
Defined in: response-sync.ts:141
HTTP status code
Returns
number
statusText
Get Signature
get statusText():
string
Defined in: response-sync.ts:146
HTTP status text
Returns
string
type
Get Signature
get type():
ResponseType
Defined in: response-sync.ts:166
Response type
Returns
ResponseType
url
Get Signature
get url():
string
Defined in: response-sync.ts:171
Response URL
Returns
string
Methods
arrayBuffer()
arrayBuffer():
ArrayBuffer
Defined in: response-sync.ts:107
Get body as ArrayBuffer (synchronous)
Returns
ArrayBuffer
ArrayBuffer representation of body
blob()
blob():
Blob
Defined in: response-sync.ts:125
Get body as Blob (synchronous)
Returns
Blob
Blob containing body data
clone()
clone():
ResponseSync
Defined in: response-sync.ts:182
Clone this ResponseSync
Returns
ResponseSync
New ResponseSync with same properties
formData()
formData():
never
Defined in: response-sync.ts:134
FormData not supported in sync mode
Returns
never
Throws
Always throws - use json() or text() instead
json()
json():
any
Defined in: response-sync.ts:71
Get body as parsed JSON (synchronous)
Returns
any
Parsed JSON object or null if no body
text()
text():
string
Defined in: response-sync.ts:89
Get body as text string (synchronous)
Returns
string
Text representation of body
toResponse()
toResponse():
Response
Defined in: response-sync.ts:197
Convert to real Response object
Useful for returning from fetch() handlers or other APIs that expect a real Response.
Returns
Response
Real Response object with body
fromResponse()
staticfromResponse(response):Promise<ResponseSync>
Defined in: response-sync.ts:226
Create a ResponseSync from a real Response object
Note: This is async because it needs to read the Response body stream. Use this when you have a real Response and need to convert it for serialization.
Parameters
response
Response
Real Response object
Returns
Promise<ResponseSync>
Promise<ResponseSync>
Example
const response = await fetch('https://api.example.com/data');
const syncResponse = await ResponseSync.fromResponse(response);
// Now can serialize syncResponse with structured-clone (sync!)