Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}
// Do not retry unless explicitly stated.
if (!opts.retry) {
opts.retry = { retries: 0 };
}
if (!opts.timeout && process.env.NODE_ENV !== "test") {
opts.timeout = 1500;
}
try {
const { body, headers, statusCode } = await got[method](url, opts);
return {
body: parseJSON(body).value,
headers,
status: statusCode,
};
} catch (error) {
throw new HttpieError(error);
}
}
}
Object.defineProperty(this, "message", {
enumerable: false,
value: error.message,
});
Object.defineProperty(this, "name", {
enumerable: false,
value: this.constructor.name,
});
if (error.response) {
Object.defineProperty(this, "response", {
enumerable: false,
value: {
body: parseJSON(error.response.body).value,
headers: error.response.headers,
status: error.response.statusCode,
},
});
}
Error.captureStackTrace(this, this.constructor);
}
}