MCPcopy Create free account
hub / github.com/EsperoTech/yaade / parseResponse

Function parseResponse

client/src/utils/parseResponseEvent.tsx:16–47  ·  view source on GitHub ↗
(res: any)

Source from the content-addressed store, hash-verified

14 headers.find((header) => header.key.toLowerCase() === 'content-type')?.value ?? '';
15
16function parseResponse(res: any): RestResponse {
17 const headers: Array<KVRow> = res.headers;
18 const contentType = getContentType(headers);
19 let body = res.body;
20 try {
21 body = beautifyBody(body, contentType);
22 } catch (e) {
23 console.error(e);
24 }
25 const size = res.size ?? getSize(headers);
26
27 const options: Intl.DateTimeFormatOptions = {
28 weekday: 'long',
29 year: 'numeric',
30 month: 'long',
31 day: 'numeric',
32 hour: '2-digit',
33 minute: '2-digit',
34 second: '2-digit',
35 timeZoneName: 'short',
36 };
37 const date = new Date().toLocaleString('en-GB', options);
38
39 return {
40 headers,
41 body,
42 status: res.status,
43 time: res.time,
44 size,
45 date,
46 };
47}
48
49export { parseResponse };

Callers 2

handleMessageFunction · 0.90
sendRequestToServerFunction · 0.90

Calls 4

beautifyBodyFunction · 0.85
getSizeFunction · 0.85
getContentTypeFunction · 0.70
toLocaleStringMethod · 0.45

Tested by

no test coverage detected