JSON.parse附带一个“reviver”函数(例如:“JSON.parse using reviver function”)。
如何将这个“复兴者”与response.json一起使用?例如:
fetch(url)
.then(a => a.json({reviver})) // unfortunately not working
.then(...)
我有一个解决方法:
fetch(url)
.then(a => a.text())
.then(b => new Promise((resolve) => resolve(JSON.parse(b, reviver))))
.then()
但它使用了更多步骤,这似乎没用。有更好的主意吗?