File tree Expand file tree Collapse file tree 2 files changed +8
-7
lines changed Expand file tree Collapse file tree 2 files changed +8
-7
lines changed Original file line number Diff line number Diff line change @@ -58,25 +58,26 @@ class ApiLogger {
5858
5959 this . originalFetch . apply ( window , arguments )
6060 . then ( ( response ) => {
61- if ( response && response . status >= 400 ) {
61+ const clonedResponse = response && response . clone ( ) ;
62+ if ( clonedResponse && clonedResponse . status >= 400 ) {
6263 body = body && this . getBody ( body ) ;
63- const contentType = response . headers . get ( "content-type" ) ;
64+ const contentType = clonedResponse . headers . get ( "content-type" ) ;
6465 const logData = {
6566 id : new Date ( ) . getTime ( ) ,
6667 url,
6768 method,
6869 body,
69- status : response . status ,
70- contentType : response . headers . get ( "content-type" )
70+ status : clonedResponse . status ,
71+ contentType : clonedResponse . headers . get ( "content-type" )
7172 }
7273 if ( contentType && contentType . includes ( "application/json" ) ) {
73- return response . clone ( ) . json ( ) . then ( ( json ) => {
74+ return clonedResponse . clone ( ) . json ( ) . then ( ( json ) => {
7475 logData . response = json
7576 store . push ( logData ) ;
7677 resolve ( response ) ;
7778 } ) ;
7879 } else {
79- return response . clone ( ) . text ( ) . then ( ( text ) => {
80+ return clonedResponse . clone ( ) . text ( ) . then ( ( text ) => {
8081 logData . response = text ;
8182 store . push ( logData ) ;
8283 resolve ( response ) ;
You can’t perform that action at this time.
0 commit comments