How to use the js-data.utils.copy function in js-data

To help you get started, we’ve selected a few js-data 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 js-data / js-data-http / src / index.js View on Github external
HTTP (config, opts) {
    const start = new Date()
    opts || (opts = {})
    const payload = config.data
    const cache = config.cache
    const timeout = config.timeout
    const params = config.params
    config = utils.copy(config, null, null, null, ['data', 'cache', 'timeout', 'params']) // params could have data, cache, timeout
    config.params = utils.copy(params)
    config = utils.deepMixIn(config, this.httpConfig)
    config.data = payload
    config.cache = cache
    if (timeout !== undefined) {
      config.timeout = timeout
    }
    if (this.forceTrailingSlash && config.url[config.url.length - 1] !== '/') {
      config.url += '/'
    }
    config.method = config.method.toUpperCase()
    const suffix = config.suffix || opts.suffix || this.suffix
    if (suffix && config.url.substr(config.url.length - suffix.length) !== suffix) {
      config.url += suffix
    }

    const logResponse = (data) => {
github js-data / js-data-http / src / index.js View on Github external
HTTP (config, opts) {
    const start = new Date()
    opts || (opts = {})
    const payload = config.data
    const cache = config.cache
    const timeout = config.timeout
    const params = config.params
    config = utils.copy(config, null, null, null, ['data', 'cache', 'timeout', 'params']) // params could have data, cache, timeout
    config.params = utils.copy(params)
    config = utils.deepMixIn(config, this.httpConfig)
    config.data = payload
    config.cache = cache
    if (timeout !== undefined) {
      config.timeout = timeout
    }
    if (this.forceTrailingSlash && config.url[config.url.length - 1] !== '/') {
      config.url += '/'
    }
    config.method = config.method.toUpperCase()
    const suffix = config.suffix || opts.suffix || this.suffix
    if (suffix && config.url.substr(config.url.length - suffix.length) !== suffix) {
      config.url += suffix
    }
github js-data / js-data-http / src / index.js View on Github external
getParams (opts) {
    opts || (opts = {})
    if (opts.params === undefined) {
      return {}
    }
    return utils.copy(opts.params)
  },