File tree 2 files changed +8
-7
lines changed
2 files changed +8
-7
lines changed Original file line number Diff line number Diff line change @@ -58,25 +58,26 @@ class ApiLogger {
58
58
59
59
this . originalFetch . apply ( window , arguments )
60
60
. then ( ( response ) => {
61
- if ( response && response . status >= 400 ) {
61
+ const clonedResponse = response && response . clone ( ) ;
62
+ if ( clonedResponse && clonedResponse . status >= 400 ) {
62
63
body = body && this . getBody ( body ) ;
63
- const contentType = response . headers . get ( "content-type" ) ;
64
+ const contentType = clonedResponse . headers . get ( "content-type" ) ;
64
65
const logData = {
65
66
id : new Date ( ) . getTime ( ) ,
66
67
url,
67
68
method,
68
69
body,
69
- status : response . status ,
70
- contentType : response . headers . get ( "content-type" )
70
+ status : clonedResponse . status ,
71
+ contentType : clonedResponse . headers . get ( "content-type" )
71
72
}
72
73
if ( contentType && contentType . includes ( "application/json" ) ) {
73
- return response . clone ( ) . json ( ) . then ( ( json ) => {
74
+ return clonedResponse . clone ( ) . json ( ) . then ( ( json ) => {
74
75
logData . response = json
75
76
store . push ( logData ) ;
76
77
resolve ( response ) ;
77
78
} ) ;
78
79
} else {
79
- return response . clone ( ) . text ( ) . then ( ( text ) => {
80
+ return clonedResponse . clone ( ) . text ( ) . then ( ( text ) => {
80
81
logData . response = text ;
81
82
store . push ( logData ) ;
82
83
resolve ( response ) ;
You can’t perform that action at this time.
0 commit comments