Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
_get() {
const apiRequestUrl = this._createApiRequestUrl();
const headers = this._createHeaders();
let requestPromise;
if (options.isThrottled(this.url.requestedUrl)) {
requestPromise = Promise.reject(new Error("throttled"));
} else {
debug("prerendering:", apiRequestUrl, headers);
requestPromise = got.get(apiRequestUrl, {
headers,
retries: options.options.retries,
followRedirect: false,
timeout: options.options.timeout || 20000
});
}
return requestPromise
.then(response => {
return createResponse(this.req, this.url.requestedUrl, response);
})
.catch(err => {
const shouldBubble = util.isFunction(options.options.bubbleUp5xxErrors)
? options.options.bubbleUp5xxErrors(err, this.req, err.response)
: options.options.bubbleUp5xxErrors;