How to use got-lite - 1 common examples

To help you get started, we’ve selected a few got-lite examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github sanfrancesco / prerendercloud-nodejs / source / index.js View on Github external
_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;

got-lite

Simplified HTTP requests

MIT
Latest version published 3 years ago

Package Health Score

45 / 100
Full package analysis

Popular got-lite functions