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    
Size: Mime:
'use strict';

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

const {
  errorHandler,
  responseHandler
} = require('./helpers/fetch');
/**
 * Get the user's info from the monolith.
 *
 * @param {string} accessToken - The user's access token
 * @returns {Promise<object>}
 */


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

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

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