There is a "reviver" function that comes with JSON.parse (eg: "JSON.parse using reviver function").
How can I use this "reviver" with response.json? for instance:
fetch(url)
.then(a => a.json({reviver})) // unfortunately not working
.then(...)
I have a workaround:
fetch(url)
.then(a => a.text())
.then(b => new Promise((resolve) => resolve(JSON.parse(b, reviver))))
.then()
but it uses one more step, which seems useless. Any better idea?
Your workaround is basically the best option but as mentioned, the extra promise is unnecessary.