diff --git a/src/plugins/network/RequestDetails.js b/src/plugins/network/RequestDetails.js index e186b84cf..9791d8f99 100644 --- a/src/plugins/network/RequestDetails.js +++ b/src/plugins/network/RequestDetails.js @@ -607,6 +607,43 @@ class GraphQLFormatter { return ; } }; + + formatResponse = (request: Request, response: Response) => { + return this.format( + decodeBody(response), + getHeaderValue(response.headers, 'content-type'), + ); + }; + + format = (body: string, contentType: string) => { + if ( + contentType.startsWith('application/json') || + contentType.startsWith('text/javascript') || + contentType.startsWith('text/html') || + contentType.startsWith('application/x-fb-flatbuffer') + ) { + try { + const data = JSON.parse(body); + return ( + + ); + } catch (SyntaxError) { + // Multiple top level JSON roots, map them one by one + const roots = body.replace(/}{/g, '}\r\n{').split('\n'); + return ( + JSON.parse(json))} + /> + ); + } + } + }; } class FormUrlencodedFormatter {