Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
url,
query,
queryNoCache,
headers,
type = 'form',
payload,
attaches = [],
timeout,
withCredentials,
abortPromise,
responseType,
} = context.getRequest();
let ended = false;
const method = httpMethod.toLowerCase();
const noBody = method === HttpMethods.GET || method === HttpMethods.HEAD;
let body;
let formHeaders;
if (attaches.length) {
body = createForm(payload, isBrowser ? attaches : []);
formHeaders = body.getHeaders && body.getHeaders();
} else {
const contentType = propOr(type, type, REQUEST_TYPES);
formHeaders = contentType ? { 'Content-type': contentType } : {};
if (!noBody) {
body = serialize(type, payload);
}
}