How to access info from GET requests to a website

Hi, folks. I’m sending a GET request to a website from a Node/Express server and trying to access some of the information that I’m receiving in the response object, but the keys are seemingly inaccessible. What I’m seeing is:

Response {
  size: 0,
  timeout: 0,
  [Symbol(Body internals)]: 
   { body: 
      Gunzip {
        _readableState: [Object],
        readable: true,
        domain: null,
        _events: [Object],
        _eventsCount: 7,
        _maxListeners: undefined,
        _writableState: [Object],
        writable: true,
        allowHalfOpen: true,
        _transformState: [Object],
        bytesRead: 0,
        _opts: [Object],
        _chunkSize: 16384,
        _flushFlag: 2,
        _finishFlushFlag: 2,
        _scheduledFlushFlag: 0,
        _handle: [Object],
        _hadError: false,
        _buffer: <Buffer b8 f2 0c 6f b9 7f 00 00 b8 f2 0c 6f b9 7f 00 00 a0 c9 b8 03 00 00 00 00 a0 c9 b8 03 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ... >,
        _offset: 0,
        _level: -1,
        _strategy: 0 },
     disturbed: false,
     error: null },
  [Symbol(Response internals)]: 
   { url: 'https://www.lexico.com/search?filter=dictionary&query=grogg',
     status: 200,
     statusText: 'OK',
     headers: Headers { [Symbol(map)]: [Object] },
     counter: 1 } }

Is there a way for me to access the information in [Symbol(Response internals)]? If I run Object.keys(response), the only keys that are shown are [size, timeout].
Thanks!

Hi @LuosRestil
I think you need to await for JSON
if you are using node-fetch see this post: https://stackoverflow.com/questions/49841983/node-fetch-problems-with-post-requests

1 Like

I am using node-fetch, but it doesn’t look like the response I’m getting back is in JSON format. If I try to await for JSON, I just get an error:
UnhandledPromiseRejectionWarning: FetchError: invalid json response body at https://www.lexico.com/search?filter=dictionary&query=whatever reason: Unexpected token < in JSON at position 0

does the URL send JSON?

No, I don’t think so.

Solved, through some experimentation. It turns out that I can access the contents of [Symbol(Response internals)] as if they are keys of “response”. response.status returns 200, response.url returns `‘https://www.lexico.com/search?filter=dictionary&query=grogg’, etc.