citi-hub-session-engine
Version:
Module for authentication methods for CITI hub
32 lines (26 loc) • 943 B
JavaScript
const { logger } = require("../utils/Logger");
const { configurations_key } = require("../utils/Constants");
const userProviders = async (token, id) => {
try {
logger.info(`Initiating Confirm User`);
const config = global[configurations_key];
let endpoint = config?.userProviders?.endpoint || "";
endpoint = endpoint.replace("{id}", id);
logger.info(`endpoint: ${endpoint}`);
//INVOKE ENDPOINT, GET, headers: authorization, body: params
const response = await fetch(endpoint, {
method: "GET",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${token}`,
},
});
const data = await response.json();
logger.info(`Response from userProviders: ${data.code}`);
return data;
} catch (e) {
logger.error(`An error occurred while userProviders :: ${e}`);
return null;
}
};
module.exports = userProviders;