如何在fetch.response.json()中使用齐磊函数>> [

问题描述 投票:2回答:2
[附带一个“恢复程序”功能(例如:"JSON.parse using reviver function")。

如何与response.json

一起使用此“ reviver”?例如:

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()

但是它又使用了一步,这似乎没有用。还有更好的主意吗?

[JSON.parse附带了一个“ reviver”函数(例如:“ JSON.parse using reviver function”)。如何在response.json中使用此“ reviver”?例如:fetch(url).then(a => a.json({...
javascript fetch-api reviver-function
2个回答
0
投票

-1
投票
© www.soinside.com 2019 - 2024. All rights reserved.