File tree Expand file tree Collapse file tree 1 file changed +10
-6
lines changed Expand file tree Collapse file tree 1 file changed +10
-6
lines changed Original file line number Diff line number Diff line change @@ -288,7 +288,14 @@ export default class Router {
288
288
}
289
289
290
290
const jsonPageRes = await this . fetchRoute ( route )
291
- const jsonData = await jsonPageRes . json ( )
291
+ let jsonData
292
+ // We can call .json() only once for a response.
293
+ // That's why we need to keep a copy of data if we already parsed it.
294
+ if ( jsonPageRes . data ) {
295
+ jsonData = jsonPageRes . data
296
+ } else {
297
+ jsonData = jsonPageRes . data = await jsonPageRes . json ( )
298
+ }
292
299
293
300
if ( jsonData . buildIdMismatch ) {
294
301
_notifyBuildIdMismatch ( as )
@@ -336,16 +343,13 @@ export default class Router {
336
343
return props
337
344
}
338
345
339
- async fetchRoute ( route ) {
346
+ fetchRoute ( route ) {
340
347
let promise = this . fetchingRoutes [ route ]
341
348
if ( ! promise ) {
342
349
promise = this . fetchingRoutes [ route ] = this . doFetchRoute ( route )
343
350
}
344
351
345
- const res = await promise
346
- // We need to clone this to prevent reading the body twice
347
- // Because it's possible only once to read res.json() or a similar method.
348
- return res . clone ( )
352
+ return promise
349
353
}
350
354
351
355
doFetchRoute ( route ) {
You can’t perform that action at this time.
0 commit comments