Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
authHeaders => {
reqOpts.headers = Object.assign({}, reqOpts.headers, authHeaders);
teenyRequest(reqOpts, (err, res, body) => {
let e = (body && body.error) ? body.error : err;
// If no error was returned, but the response had an invalid status
// code, create a new error to be passed to the callback.
if (!e && (res.statusCode < 200 || res.statusCode >= 300) &&
res.statusCode !== RESUMABLE_INCOMPLETE_STATUS_CODE) {
e = new Error(`The request failed with a ${res.statusCode}.`);
e.code = res.statusCode;
}
callback(e, res, body);
});
},
e => {
request: (options: t.Options, cb: t.RequestCallback) => {
teenyRequest(options, (err, r) => {
cb(err, r ? r.body : undefined, r);
});
},
} as {}) as Debug;