MCPcopy Index your code
hub / github.com/triggerdotdev/trigger.dev / safeBodyFromResponse

Function safeBodyFromResponse

apps/webapp/app/utils/json.ts:33–49  ·  view source on GitHub ↗
(
  response: Response,
  schema: z.Schema<T>
)

Source from the content-addressed store, hash-verified

31}
32
33export async function safeBodyFromResponse<T>(
34 response: Response,
35 schema: z.Schema<T>
36): Promise<T | undefined> {
37 const json = await response.text();
38 const unknownJson = safeJsonParse(json);
39
40 if (!unknownJson) {
41 return;
42 }
43
44 const parsedJson = schema.safeParse(unknownJson);
45
46 if (parsedJson.success) {
47 return parsedJson.data;
48 }
49}
50
51export async function safeParseBodyFromResponse<T>(
52 response: Response,

Callers 3

pingMethod · 0.90
validateMethod · 0.90
callMethod · 0.90

Calls 2

safeJsonParseFunction · 0.70
textMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…