How to use the minipass-fetch.isRedirect function in minipass-fetch

To help you get started, we’ve selected a few minipass-fetch 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 npm / make-fetch-happen / index.js View on Github external
res.status === 408 || // Request Timeout
              res.status === 420 || // Enhance Your Calm (usually Twitter rate-limit)
              res.status === 429 || // Too Many Requests ("standard" rate-limiting)
              res.status >= 500 // Assume server errors are momentary hiccups
            )
          )

          if (isRetriable) {
            if (typeof opts.onRetry === 'function') {
              opts.onRetry(res)
            }

            return retryHandler(res)
          }

          if (!fetch.isRedirect(res.status)) {
            return res
          }
          if (opts.redirect === 'manual') {
            return res
          }
          // if (!fetch.isRedirect(res.status) || opts.redirect === 'manual') {
          //   return res
          // }

          // handle redirects - matches behavior of fetch: https://github.com/bitinn/node-fetch
          if (opts.redirect === 'error') {
            const err = new fetch.FetchError(`redirect mode is set to error: ${uri}`, 'no-redirect', { code: 'ENOREDIRECT' })
            throw err
          }

          if (!res.headers.get('location')) {

minipass-fetch

An implementation of window.fetch in Node.js using Minipass streams

MIT
Latest version published 4 months ago

Package Health Score

88 / 100
Full package analysis