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 / getAllSubscriptionsForUser.js
Size: Mime:
'use strict';

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

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


function getAllSubscriptionsForUser(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/list`;
  const headers = {
    'Content-Type': 'application/json',
    Accept: 'application/json',
    Authorization: `Bearer ${accessToken}`
  };
  return fetch(url, {
    method: 'GET',
    headers
  }).then(responseHandler).catch(errorHandler);
}

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