Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
@doodle/billing-client / dist / index.cjs.js / getActiveSubscriptionsForUser.js
Size: Mime:
'use strict';

const fetch = require('fetch-everywhere');

const {
  errorHandler,
  responseHandler
} = require('./helpers/fetch');
/**
 * Get active subscriptions for a user.
 *
 * @param {string} accessToken - The user's access-token
 * @returns {Object}
 */


function getActiveSubscriptionsForUser(accessToken) {
  if (typeof accessToken !== 'string') {
    throw new TypeError(`accessToken param must be a string, got ${typeof accessToken}`);
  }

  const url = `${process.env.SVC_BILLING_BASE_URL}/subscriptions`;
  const headers = {
    'Content-Type': 'application/json',
    Authorization: `Bearer ${accessToken}`,
    Accept: 'application/json'
  };
  return fetch(url, {
    method: 'GET',
    headers
  }).then(responseHandler).catch(errorHandler);
}

module.exports = getActiveSubscriptionsForUser;
//# sourceMappingURL=getActiveSubscriptionsForUser.js.map