How to use the ky/umd.extend function in ky

To help you get started, we’ve selected a few ky 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 digidem / mapeo-desktop / src / renderer / new-api.js View on Github external
export function Api ({ baseUrl }) {
  // We append this to requests for presets and map styles, in order to override
  // the local static server cache whenever the app is restarted. NB. sprite,
  // font, and map tile requests might still be cached, only changes in the map
  // style will be cache-busted.
  const startupTime = Date.now()

  const req = ky.extend({
    prefixUrl: baseUrl,
    // No timeout because indexing after first sync takes a long time, which mean
    // requests to the server take a long time
    timeout: false,
    headers: {
      'cache-control': 'no-cache',
      pragma: 'no-cache'
    }
  })

  function logRequest (prefix, promise) {
    const start = Date.now()
    promise
      .then(data => {
        logger.log(prefix, Date.now() - start + 'ms')
      })

ky

Tiny and elegant HTTP client based on the Fetch API

MIT
Latest version published 2 months ago

Package Health Score

94 / 100
Full package analysis