MCPcopy
hub / github.com/prisma/prisma / request

Function request

packages/internals/src/errorReporting.ts:62–90  ·  view source on GitHub ↗
(query: string, variables: any)

Source from the content-addressed store, hash-verified

60}
61
62async function request(query: string, variables: any): Promise<any> {
63 const url = 'https://error-reports.prisma.sh/'
64 const body = JSON.stringify({
65 query,
66 variables,
67 })
68
69 return await fetch(url, {
70 method: 'POST',
71 agent: getProxyAgent(url),
72 body,
73 headers: {
74 Accept: 'application/json',
75 'Content-Type': 'application/json',
76 },
77 })
78 .then((response) => {
79 if (!response.ok) {
80 throw new Error(`Error during request: ${response.status} ${response.statusText} - Query: ${query}`)
81 }
82 return response.json() as any
83 })
84 .then((responseAsJson) => {
85 if (responseAsJson.errors) {
86 throw new Error(JSON.stringify(responseAsJson.errors))
87 }
88 return responseAsJson.data
89 })
90}

Callers 2

createErrorReportFunction · 0.85
makeErrorReportCompletedFunction · 0.85

Calls 3

getProxyAgentFunction · 0.90
thenMethod · 0.65
fetchFunction · 0.50

Tested by

no test coverage detected