Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export async function query(doc: string, headers = {}): Promise<{ data: any, errors: any }> {
const res = await fetch(url, {
method: 'POST',
headers: Object.assign({ 'Content-Type': 'application/json' }, headers),
body: JSON.stringify({ query: doc }),
});
return res.json();
}
async () => {
const curResponse = await fetch(endpointUrl, {
method: 'POST',
headers: {
'user-agent': 'apollo-engine-reporting',
'x-api-key': this.apiKey,
'content-encoding': 'gzip',
},
body: compressed,
agent: this.options.requestAgent,
});
if (curResponse.status >= 500 && curResponse.status < 600) {
throw new Error(
`HTTP status ${curResponse.status}, ${(await curResponse.text()) ||
'(no body)'}`,
);
} else {