Re: [whatwg/fetch] String representations for Fetch API objects (Issue #1575)

Thank you @annevk for reading and responding.

> Stringification of URL objects is there because it helps when writing code.

I couldn't agree more. Really, a `console.log`-able representation of each of these objects is the core of this request. Thank you and kudos to the Firefox team for a smooth dev experience with `Headers`.

> `toJSON()` for `Headers` could be reasonable though

The best alternative I've found so far, but definitely open to anything better:

```js
Object.fromEntries(headers.entries())
```
<img width="287" alt="Screenshot 2022-12-19 at 9 12 07 PM" src="https://user-images.githubusercontent.com/171897/208588739-90daa9ca-d9c9-4a48-ac0f-008b2ba96910.png">

Under the hood in the debug logs for the Axios fetch adapter, we need to call that `fromEntries(...entries())` for each log statement which is presumably rather expensive vs. what an internal representation could do.


-- 
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/fetch/issues/1575#issuecomment-1358851379
You are receiving this because you are subscribed to this thread.

Message ID: <whatwg/fetch/issues/1575/1358851379@github.com>

Received on Tuesday, 20 December 2022 05:13:38 UTC