Repository URL to install this package:
|
Version:
2.0.0-rc.7 ▾
|
'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