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');
/**
* 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