提交 d32e69ee 编写于 作者: A Arunoda Susiripala 提交者: Leo Lamprecht

Get rid of res.clone() (#1567)

Usually res.clone() should work. But it's not working with
the laster Safari (10.1)
We need to use a method we do not clone
上级 66ab661d
...@@ -288,7 +288,14 @@ export default class Router { ...@@ -288,7 +288,14 @@ export default class Router {
} }
const jsonPageRes = await this.fetchRoute(route) const jsonPageRes = await this.fetchRoute(route)
const jsonData = await jsonPageRes.json() let jsonData
// We can call .json() only once for a response.
// That's why we need to keep a copy of data if we already parsed it.
if (jsonPageRes.data) {
jsonData = jsonPageRes.data
} else {
jsonData = jsonPageRes.data = await jsonPageRes.json()
}
if (jsonData.buildIdMismatch) { if (jsonData.buildIdMismatch) {
_notifyBuildIdMismatch(as) _notifyBuildIdMismatch(as)
...@@ -336,16 +343,13 @@ export default class Router { ...@@ -336,16 +343,13 @@ export default class Router {
return props return props
} }
async fetchRoute (route) { fetchRoute (route) {
let promise = this.fetchingRoutes[route] let promise = this.fetchingRoutes[route]
if (!promise) { if (!promise) {
promise = this.fetchingRoutes[route] = this.doFetchRoute(route) promise = this.fetchingRoutes[route] = this.doFetchRoute(route)
} }
const res = await promise return promise
// We need to clone this to prevent reading the body twice
// Because it's possible only once to read res.json() or a similar method.
return res.clone()
} }
doFetchRoute (route) { doFetchRoute (route) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册