MCPcopy Create free account
hub / github.com/ShaanCoding/makeread.me / getResponseBody

Function getResponseBody

frontend/openAPI/generated/core/request.ts:232–250  ·  view source on GitHub ↗
(response: Response)

Source from the content-addressed store, hash-verified

230};
231
232export const getResponseBody = async (response: Response): Promise<any> => {
233 if (response.status !== 204) {
234 try {
235 const contentType = response.headers.get('Content-Type');
236 if (contentType) {
237 const jsonTypes = ['application/json', 'application/problem+json']
238 const isJSON = jsonTypes.some(type => contentType.toLowerCase().startsWith(type));
239 if (isJSON) {
240 return await response.json();
241 } else {
242 return await response.text();
243 }
244 }
245 } catch (error) {
246 console.error(error);
247 }
248 }
249 return undefined;
250};
251
252export const catchErrorCodes = (options: ApiRequestOptions, result: ApiResult): void => {
253 const errors: Record<number, string> = {

Callers 1

requestFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected