I am issuing a request with node-fetch
and receiving the following response (as it appears when I console.log
it):
Response {
size: 0,
timeout: 0,
[Symbol(Body internals)]: {
body: Gunzip {
_writeState: [Uint32Array],
_readableState: [ReadableState],
_events: [Object: null prototype],
_eventsCount: 5,
_maxListeners: undefined,
_writableState: [WritableState],
allowHalfOpen: true,
bytesWritten: 0,
_handle: [Zlib],
_outBuffer: <Buffer 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 c0 bd 60 05 00 00 00 00 c0 bd 60 05 00 00 00 00 08 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 28 be ... 16334 more bytes>,
_outOffset: 0,
_chunkSize: 16384,
_defaultFlushFlag: 2,
_finishFlushFlag: 2,
_defaultFullFlushFlag: 3,
_info: undefined,
_maxOutputLength: 4294967295,
_level: -1,
_strategy: 0,
[Symbol(kCapture)]: false,
[Symbol(kTransformState)]: [Object],
[Symbol(kError)]: null
},
disturbed: false,
error: null
},
[Symbol(Response internals)]: {
url: 'https://accounts.spotify.com/api/token',
status: 200,
statusText: 'OK',
headers: Headers { [Symbol(map)]: [Object: null prototype] },
counter: 0
}
}
My question
How do I extract everything under [Symbol(Response internals)]
as an object?
Clarification
I am aware that the individual properties listed under [Symbol(Response internals)]
can be accessed as properties of my response. For instance,
const response = await fetch(..);
console.log(response.statusText)
will give me back that 'OK' string. I am also aware of this thread, which solves that problem (but not mine).
What I asking is how to reify [Symbol(Response internals)]
as a whole and refer to it.
Additional comments
I (think I) know what Symbol does, and I can retrieve the symbols
[Symbol(Body internals), Symbol(Response internals)]
by running Object.getOwnPropertySymbols() on my response
.
But how to extract the values (objects) attached to those symbols?
Object.values() doesn't do this, and Object.entries() doesn't either.