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

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

const {
  errorHandler,
  responseHandler
} = require('./helpers/fetch');
/**
 * Log the monolith user in and get the user's data in return.
 *
 * @param {string} email - The user's email address
 * @param {string} password - The user's password
 * @returns {Promise}
 */


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

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

  const url = `${process.env.MONOLITH_API_BASE_URL}/api/v2.0/users/oauth/token`;
  const headers = {
    'Content-Type': 'application/json',
    Accept: 'application/json'
  };
  return fetch(url, {
    method: 'POST',
    headers,
    body: JSON.stringify({
      email,
      password
    })
  }).then(responseHandler).catch(errorHandler);
}

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