MCPcopy Create free account
hub / github.com/langgenius/dify / parseJsonBody

Function parseJsonBody

cli/src/http/client.ts:269–274  ·  view source on GitHub ↗
(res: Response)

Source from the content-addressed store, hash-verified

267// letting `res.json()` throw an unclassified SyntaxError, so void-returning callers
268// (revoke, stopTask, …) stay safe when a server replies with No Content.
269async function parseJsonBody<T>(res: Response): Promise<T> {
270 if (res.status === 204 || res.status === 205)
271 return undefined as T
272 const text = await res.text()
273 return (text === '' ? undefined : JSON.parse(text)) as T
274}
275
276export function createHttpClient(opts: ClientOptions): HttpClient {
277 const state = compileState(opts)

Callers 1

typedCallFunction · 0.85

Calls 2

textMethod · 0.45
parseMethod · 0.45

Tested by

no test coverage detected