(query: string, variables: any)
| 60 | } |
| 61 | |
| 62 | async 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 | } |
no test coverage detected