1
0
Fork 0
mirror of https://github.com/terribleplan/next.js.git synced 2024-01-19 02:48:18 +00:00

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
This commit is contained in:
Arunoda Susiripala 2017-03-30 19:39:31 +05:30 committed by Leo Lamprecht
parent 66ab661d4c
commit d32e69eeb9

View file

@ -288,7 +288,14 @@ export default class Router {
}
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) {
_notifyBuildIdMismatch(as)
@ -336,16 +343,13 @@ export default class Router {
return props
}
async fetchRoute (route) {
fetchRoute (route) {
let promise = this.fetchingRoutes[route]
if (!promise) {
promise = this.fetchingRoutes[route] = this.doFetchRoute(route)
}
const res = await 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()
return promise
}
doFetchRoute (route) {