lib/utils.js
function createHeaders(options) {
  const opts = Object.assign({}, options);
  const headers = Object.assign({}, defaultHeaders, lowercaseKeys(opts.headers || {}));

  if (!opts.bearer && !opts.token && !opts.username && !opts.password) {
    return headers;
  }

  if (opts.token) {
    headers['authorization'] = 'token ' + opts.token;
    return headers;
  }

  if (opts.bearer) {
    headers['authorization'] = 'Bearer ' + opts.bearer;
    return headers;
  }

  const creds = opts.username + ':' + opts.password;
  headers['authorization'] = 'Basic ' + toBase64(creds);
  return headers;
}
function createHeaders(options) {
  const opts = Object.assign({}, options);
  const headers = Object.assign({}, defaultHeaders, lowercaseKeys(opts.headers || {}));

  if (!opts.bearer && !opts.token && !opts.username && !opts.password) {
    return headers;
  }

  if (opts.token) {
    headers['authorization'] = 'token ' + opts.token;
    return headers;
  }

  if (opts.bearer) {
    headers['authorization'] = 'Bearer ' + opts.bearer;
    return headers;
  }

  const creds = opts.username + ':' + opts.password;
  headers['authorization'] = 'Basic ' + toBase64(creds);
  return headers;
}
function createHeaders ( options ) { const opts = Object . assign ( { } , options ) ; const headers = Object . assign ( { } , defaultHeaders , lowercaseKeys ( opts . headers || { } ) ) ; if ( ! opts . bearer && ! opts . token && ! opts . username && ! opts . password ) { return headers ; } if ( opts . token ) { headers [ 'authorization' ] = 'token ' + opts . token ; return headers ; } if ( opts . bearer ) { headers [ 'authorization' ] = 'Bearer ' + opts . bearer ; return headers ; } const creds = opts . username + ':' + opts . password ; headers [ 'authorization' ] = 'Basic ' + toBase64 ( creds ) ; return headers ; }
Create auth string - token, Bearer or Basic Auth
Create auth string - token Bearer or Basic Auth